Skip to content

Commit

Permalink
Allow MMCIF parser to handle multiple models.
Browse files Browse the repository at this point in the history
Code from Paul T. Bathen, see issue 2943.
  • Loading branch information
Lenna X. Peterson authored and peterjc committed Apr 23, 2012
1 parent acc5cef commit d8d4c58
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Bio/PDB/MMCIFParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def _build_structure(self, structure_id):
b_factor_list=mmcif_dict["_atom_site.B_iso_or_equiv"]
occupancy_list=mmcif_dict["_atom_site.occupancy"]
fieldname_list=mmcif_dict["_atom_site.group_PDB"]
model_list = mmcif_dict["_atom_site.pdbx_PDB_model_num"]
try:
aniso_u11=mmcif_dict["_atom_site.aniso_U[1][1]"]
aniso_u12=mmcif_dict["_atom_site.aniso_U[1][2]"]
Expand All @@ -54,11 +55,12 @@ def _build_structure(self, structure_id):
# Now loop over atoms and build the structure
current_chain_id=None
current_residue_id=None
current_model_id=0
#current_model_id=0
structure_builder=self._structure_builder
structure_builder.init_structure(structure_id)
structure_builder.init_model(current_model_id)
#structure_builder.init_model(current_model_id)
structure_builder.init_seg(" ")
current_model_id = None
for i in xrange(0, len(atom_id_list)):
x=x_list[i]
y=y_list[i]
Expand All @@ -77,6 +79,10 @@ def _build_structure(self, structure_id):
hetatm_flag="H"
else:
hetatm_flag=" "
model_id = model_list[i]
if current_model_id != model_id:
current_model_id = model_id
structure_builder.init_model(current_model_id)
if current_chain_id!=chainid:
current_chain_id=chainid
structure_builder.init_chain(current_chain_id)
Expand Down Expand Up @@ -132,6 +138,9 @@ def _get_icode(self, resseq):
if __name__=="__main__":
import sys

if len(sys.argv) != 2:
print "Usage: python MMCIFparser.py filename"
raise SystemExit
filename=sys.argv[1]

p=MMCIFParser()
Expand Down

0 comments on commit d8d4c58

Please sign in to comment.