Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
369b3c40
Commit
369b3c40
authored
14 years ago
by
Ansgar Philippsen
Browse files
Options
Downloads
Patches
Plain Diff
fix to mae import
parent
cd43e526
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/io/src/mol/entity_io_mae_handler.cc
+34
-27
34 additions, 27 deletions
modules/io/src/mol/entity_io_mae_handler.cc
with
34 additions
and
27 deletions
modules/io/src/mol/entity_io_mae_handler.cc
+
34
−
27
View file @
369b3c40
...
@@ -58,7 +58,7 @@ using boost::format;
...
@@ -58,7 +58,7 @@ using boost::format;
if
(
in_string
)
{
if
(
in_string
)
{
if
(
line
[
p1
]
==
'"'
)
{
if
(
line
[
p1
]
==
'"'
)
{
in_string
=
false
;
in_string
=
false
;
nrvo
.
push_back
(
line
.
substr
(
p0
,
p1
-
p0
));
nrvo
.
push_back
(
std
::
string
(
line
.
substr
(
p0
,
p1
-
p0
))
)
;
++
p1
;
++
p1
;
p0
=
p1
;
p0
=
p1
;
while
(
isspace
(
line
[
p1
])
&&
p1
<
line
.
size
())
{
++
p0
;
++
p1
;}
while
(
isspace
(
line
[
p1
])
&&
p1
<
line
.
size
())
{
++
p0
;
++
p1
;}
...
@@ -66,7 +66,7 @@ using boost::format;
...
@@ -66,7 +66,7 @@ using boost::format;
}
}
}
else
{
}
else
{
if
(
isspace
(
line
[
p1
]))
{
if
(
isspace
(
line
[
p1
]))
{
nrvo
.
push_back
(
line
.
substr
(
p0
+
1
,
p1
-
p0
-
1
));
nrvo
.
push_back
(
std
::
string
(
line
.
substr
(
p0
+
1
,
p1
-
p0
-
1
))
)
;
++
p1
;
++
p1
;
p0
=
p1
;
p0
=
p1
;
while
(
isspace
(
line
[
p1
])
&&
p1
<
line
.
size
())
{
++
p0
;
++
p1
;}
while
(
isspace
(
line
[
p1
])
&&
p1
<
line
.
size
())
{
++
p0
;
++
p1
;}
...
@@ -120,31 +120,39 @@ void MAEReader::Import(mol::EntityHandle& ent)
...
@@ -120,31 +120,39 @@ void MAEReader::Import(mol::EntityHandle& ent)
int
i_chain_name
=-
1
;
int
i_chain_name
=-
1
;
mol
::
XCSEditor
editor
=
ent
.
EditXCS
(
mol
::
BUFFERED_EDIT
);
mol
::
XCSEditor
editor
=
ent
.
EditXCS
(
mol
::
BUFFERED_EDIT
);
while
(
std
::
getline
(
in_
,
line
))
{
while
(
std
::
getline
(
in_
,
line
))
{
line
=
boost
::
trim_copy
(
line
);
line
=
boost
::
trim_copy
(
line
);
if
(
in_ct_block
)
{
if
(
in_ct_block
)
{
if
(
in_atom_block
)
{
if
(
in_atom_block
)
{
if
(
parsing_atoms
)
{
if
(
parsing_atoms
)
{
if
(
boost
::
regex_match
(
line
,
r_delim
))
{
if
(
boost
::
regex_match
(
line
,
r_delim
))
{
//
LOG_
DEBUG
( "stopping atom parsing" );
LOG_
TRACE
(
"stopping atom parsing"
);
parsing_atoms
=
false
;
parsing_atoms
=
false
;
prop_list
.
clear
();
prop_list
.
clear
();
i_atom_name
=-
1
;
i_atom_xpos
=-
1
;
i_atom_ypos
=-
1
;
i_atom_zpos
=-
1
;
i_res_name
=-
1
;
i_res_num
=-
1
;
i_chain_name
=-
1
;
}
else
{
}
else
{
// parsing atom line
// parsing atom line
std
::
vector
<
std
::
string
>
tokens
=
tokenize
(
line
);
std
::
vector
<
std
::
string
>
tokens
=
tokenize
(
line
);
for
(
size_t
i
=
0
;
i
<
tokens
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
tokens
.
size
();
++
i
)
{
//
LOG_
DEBUG
( "[" << tokens[i] << "] ");
LOG_
TRACE
(
"["
<<
tokens
[
i
]
<<
"] "
);
}
}
//LOG_DEBUG("");
LOG_TRACE
(
""
);
add_atom
(
ent
,
editor
,
add_atom
(
ent
,
editor
,
tokens
[
i_atom_name
],
i_atom_name
>=
0
&&
i_atom_name
<
(
int
)
tokens
.
size
()
?
tokens
[
i_atom_name
]
:
"X"
,
tokens
[
i_atom_xpos
],
i_atom_xpos
>=
0
&&
i_atom_xpos
<
(
int
)
tokens
.
size
()
?
tokens
[
i_atom_xpos
]
:
"0"
,
tokens
[
i_atom_ypos
],
i_atom_ypos
>=
0
&&
i_atom_ypos
<
(
int
)
tokens
.
size
()
?
tokens
[
i_atom_ypos
]
:
"0"
,
tokens
[
i_atom_zpos
],
i_atom_zpos
>=
0
&&
i_atom_zpos
<
(
int
)
tokens
.
size
()
?
tokens
[
i_atom_zpos
]
:
"0"
,
tokens
[
i_res_name
],
i_res_name
>=
0
&&
i_res_name
<
(
int
)
tokens
.
size
()
?
tokens
[
i_res_name
]
:
"X"
,
tokens
[
i_res_num
],
i_res_num
>=
0
&&
i_res_num
<
(
int
)
tokens
.
size
()
?
tokens
[
i_res_num
]
:
"0"
,
tokens
[
i_chain_name
]);
i_chain_name
>=
0
&&
i_chain_name
<
(
int
)
tokens
.
size
()
?
tokens
[
i_chain_name
]
:
"X"
);
}
}
}
else
{
// not parsing atoms
}
else
{
// not parsing atoms
if
(
boost
::
regex_match
(
line
,
r_delim
))
{
if
(
boost
::
regex_match
(
line
,
r_delim
))
{
...
@@ -153,21 +161,20 @@ void MAEReader::Import(mol::EntityHandle& ent)
...
@@ -153,21 +161,20 @@ void MAEReader::Import(mol::EntityHandle& ent)
i_atom_ypos
==-
1
||
i_atom_ypos
==-
1
||
i_atom_zpos
==-
1
||
i_atom_zpos
==-
1
||
i_res_name
==-
1
||
i_res_name
==-
1
||
i_res_num
==-
1
||
i_res_num
==-
1
)
{
i_chain_name
==-
1
)
{
throw
IOException
(
"missing atom prop"
);
throw
IOException
(
"missing atom prop"
);
}
}
//
LOG_
DEBUG
( "starting atom parsing" );
LOG_
TRACE
(
"starting atom parsing"
);
parsing_atoms
=
true
;
parsing_atoms
=
true
;
}
else
if
(
line
[
0
]
==
'}'
)
{
}
else
if
(
line
[
0
]
==
'}'
)
{
//
LOG_
DEBUG
( "exiting atom block" );
LOG_
TRACE
(
"exiting atom block"
);
in_atom_block
=
false
;
in_atom_block
=
false
;
}
else
{
}
else
{
// parsing property line
// parsing property line
if
(
line
[
0
]
!=
'#'
)
{
if
(
line
[
0
]
!=
'#'
)
{
int
pid
=
prop_list
.
size
()
+
1
;
int
pid
=
prop_list
.
size
()
+
1
;
prop_list
.
push_back
(
line
);
prop_list
.
push_back
(
line
);
//
LOG_
DEBUG
( "found property '" << prop_list.back() << "' id=" << pid );
LOG_
TRACE
(
"found property '"
<<
prop_list
.
back
()
<<
"' id="
<<
pid
);
if
(
line
==
"s_m_pdb_atom_name"
)
i_atom_name
=
pid
;
if
(
line
==
"s_m_pdb_atom_name"
)
i_atom_name
=
pid
;
else
if
(
line
==
"r_m_x_coord"
)
i_atom_xpos
=
pid
;
else
if
(
line
==
"r_m_x_coord"
)
i_atom_xpos
=
pid
;
else
if
(
line
==
"r_m_y_coord"
)
i_atom_ypos
=
pid
;
else
if
(
line
==
"r_m_y_coord"
)
i_atom_ypos
=
pid
;
...
@@ -180,16 +187,16 @@ void MAEReader::Import(mol::EntityHandle& ent)
...
@@ -180,16 +187,16 @@ void MAEReader::Import(mol::EntityHandle& ent)
}
}
}
else
{
// not in atom block
}
else
{
// not in atom block
if
(
boost
::
regex_match
(
line
,
r_atom_block
))
{
if
(
boost
::
regex_match
(
line
,
r_atom_block
))
{
//
LOG_
DEBUG
( "entering atom block" );
LOG_
TRACE
(
"entering atom block"
);
in_atom_block
=
true
;
in_atom_block
=
true
;
}
else
if
(
line
[
0
]
==
'}'
)
{
}
else
if
(
line
[
0
]
==
'}'
)
{
//
LOG_
DEBUG
( "exiting ct block" );
LOG_
TRACE
(
"exiting ct block"
);
in_ct_block
=
false
;
in_ct_block
=
false
;
}
}
}
}
}
else
{
// not in ct block
}
else
{
// not in ct block
if
(
boost
::
regex_match
(
line
,
r_ct_block
))
{
if
(
boost
::
regex_match
(
line
,
r_ct_block
))
{
//
LOG_
DEBUG
( "entering ct block" );
LOG_
TRACE
(
"entering ct block"
);
in_ct_block
=
true
;
in_ct_block
=
true
;
}
}
}
}
...
@@ -213,7 +220,7 @@ void MAEReader::add_atom(mol::EntityHandle ent,
...
@@ -213,7 +220,7 @@ void MAEReader::add_atom(mol::EntityHandle ent,
std
::
string
aname
=
boost
::
trim_copy
(
aname2
);
std
::
string
aname
=
boost
::
trim_copy
(
aname2
);
std
::
string
rname
=
boost
::
trim_copy
(
rname2
);
std
::
string
rname
=
boost
::
trim_copy
(
rname2
);
std
::
string
cname
=
boost
::
trim_copy
(
cname2
);
std
::
string
cname
=
boost
::
trim_copy
(
cname2
);
std
::
string
ele
=
aname
.
substr
(
0
,
1
);
std
::
string
ele
=
aname
.
empty
()
?
"X"
:
aname
.
substr
(
0
,
1
);
if
(
isdigit
(
ele
[
0
]))
ele
=
"H"
;
if
(
isdigit
(
ele
[
0
]))
ele
=
"H"
;
int
irnum
=
atoi
(
s_rnum
.
c_str
());
int
irnum
=
atoi
(
s_rnum
.
c_str
());
...
@@ -245,10 +252,10 @@ void MAEReader::add_atom(mol::EntityHandle ent,
...
@@ -245,10 +252,10 @@ void MAEReader::add_atom(mol::EntityHandle ent,
if
(
update_chain
)
{
if
(
update_chain
)
{
if
(
!
(
curr_chain_
=
ent
.
FindChain
(
cname
)))
{
if
(
!
(
curr_chain_
=
ent
.
FindChain
(
cname
)))
{
curr_chain_
=
editor
.
InsertChain
(
cname
);
curr_chain_
=
editor
.
InsertChain
(
cname
);
//
LOG_
DEBUG
("new chain " << curr_chain_);
LOG_
TRACE
(
"new chain "
<<
curr_chain_
);
++
chain_count_
;
++
chain_count_
;
}
else
{
}
else
{
//
LOG_
DEBUG
("old chain " << curr_chain_);
LOG_
TRACE
(
"old chain "
<<
curr_chain_
);
}
}
}
}
...
@@ -256,15 +263,15 @@ void MAEReader::add_atom(mol::EntityHandle ent,
...
@@ -256,15 +263,15 @@ void MAEReader::add_atom(mol::EntityHandle ent,
if
(
!
(
curr_residue_
=
curr_chain_
.
FindResidue
(
rnum
)))
{
if
(
!
(
curr_residue_
=
curr_chain_
.
FindResidue
(
rnum
)))
{
curr_residue_
=
editor
.
AppendResidue
(
curr_chain_
,
rkey
,
rnum
);
curr_residue_
=
editor
.
AppendResidue
(
curr_chain_
,
rkey
,
rnum
);
assert
(
curr_residue_
.
IsValid
());
assert
(
curr_residue_
.
IsValid
());
//
LOG_
DEBUG
(" new residue " << curr_residue_);
LOG_
TRACE
(
" new residue "
<<
curr_residue_
);
++
residue_count_
;
++
residue_count_
;
}
else
{
}
else
{
//
LOG_
DEBUG
(" old residue " << curr_residue_);
LOG_
TRACE
(
" old residue "
<<
curr_residue_
);
}
}
}
}
// finally add atom
// finally add atom
//
LOG_
DEBUG
(" atom " << aname << " (" << ele << ") @" << apos);
LOG_
TRACE
(
" atom "
<<
aname
<<
" ("
<<
ele
<<
") @"
<<
apos
);
mol
::
AtomHandle
ah
=
editor
.
InsertAtom
(
curr_residue_
,
aname
,
apos
,
ele
);
mol
::
AtomHandle
ah
=
editor
.
InsertAtom
(
curr_residue_
,
aname
,
apos
,
ele
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment