Back to index

python-biopython  1.60
Public Member Functions | Private Member Functions | Private Attributes
Bio.PDB.MMCIFParser.MMCIFParser Class Reference

List of all members.

Public Member Functions

def get_structure

Private Member Functions

def _build_structure
def _get_icode

Private Attributes

 _mmcif_dict
 _structure_builder

Detailed Description

Definition at line 18 of file MMCIFParser.py.


Member Function Documentation

def Bio.PDB.MMCIFParser.MMCIFParser._build_structure (   self,
  structure_id 
) [private]

Definition at line 25 of file MMCIFParser.py.

00025 
00026     def _build_structure(self, structure_id):
00027         mmcif_dict=self._mmcif_dict
00028         atom_id_list=mmcif_dict["_atom_site.label_atom_id"]
00029         residue_id_list=mmcif_dict["_atom_site.label_comp_id"]
00030         try:
00031             element_list = mmcif_dict["_atom_site.type_symbol"]
00032         except KeyError:
00033             element_list = None
00034         seq_id_list=mmcif_dict["_atom_site.label_seq_id"]
00035         chain_id_list=mmcif_dict["_atom_site.label_asym_id"]
00036         x_list=map(float, mmcif_dict["_atom_site.Cartn_x"])
00037         y_list=map(float, mmcif_dict["_atom_site.Cartn_y"])
00038         z_list=map(float, mmcif_dict["_atom_site.Cartn_z"])
00039         alt_list=mmcif_dict["_atom_site.label_alt_id"]
00040         b_factor_list=mmcif_dict["_atom_site.B_iso_or_equiv"]
00041         occupancy_list=mmcif_dict["_atom_site.occupancy"]
00042         fieldname_list=mmcif_dict["_atom_site.group_PDB"]
00043         try:
00044             serial_list = [int(n) for n in mmcif_dict["_atom_site.pdbx_PDB_model_num"]]
00045         except KeyError:
00046             # No model number column
00047             serial_list = None
00048         except ValueError:
00049             # Invalid model number (malformed file)
00050             raise PDBConstructionException("Invalid model number")
00051         try:
00052             aniso_u11=mmcif_dict["_atom_site.aniso_U[1][1]"]
00053             aniso_u12=mmcif_dict["_atom_site.aniso_U[1][2]"]
00054             aniso_u13=mmcif_dict["_atom_site.aniso_U[1][3]"]
00055             aniso_u22=mmcif_dict["_atom_site.aniso_U[2][2]"]
00056             aniso_u23=mmcif_dict["_atom_site.aniso_U[2][3]"]
00057             aniso_u33=mmcif_dict["_atom_site.aniso_U[3][3]"]
00058             aniso_flag=1
00059         except KeyError:
00060             # no anisotropic B factors
00061             aniso_flag=0
00062         # if auth_seq_id is present, we use this.
00063         # Otherwise label_seq_id is used.
00064         if "_atom_site.auth_seq_id" in mmcif_dict:
00065             seq_id_list=mmcif_dict["_atom_site.auth_seq_id"]
00066         else:
00067             seq_id_list=mmcif_dict["_atom_site.label_seq_id"]
00068         # Now loop over atoms and build the structure
00069         current_chain_id=None
00070         current_residue_id=None
00071         structure_builder=self._structure_builder
00072         structure_builder.init_structure(structure_id)
00073         structure_builder.init_seg(" ")
00074         # Historically, Biopython PDB parser uses model_id to mean array index
00075         # so serial_id means the Model ID specified in the file
00076         current_model_id = 0
00077         current_serial_id = 0 
00078         for i in xrange(0, len(atom_id_list)):
00079             x=x_list[i]
00080             y=y_list[i]
00081             z=z_list[i]
00082             resname=residue_id_list[i]
00083             chainid=chain_id_list[i]
00084             altloc=alt_list[i]
00085             if altloc==".":
00086                 altloc=" "
00087             resseq=seq_id_list[i]
00088             name=atom_id_list[i]
00089             tempfactor=b_factor_list[i]
00090             occupancy=occupancy_list[i]
00091             fieldname=fieldname_list[i]
00092             if fieldname=="HETATM":
00093                 hetatm_flag="H"
00094             else:
00095                 hetatm_flag=" "
00096             if serial_list is not None:
00097                 # model column exists; use it
00098                 serial_id = serial_list[i]
00099                 if current_serial_id != serial_id:
00100                     # if serial changes, update it and start new model
00101                     current_serial_id = serial_id
00102                     structure_builder.init_model(current_model_id, current_serial_id)
00103                     current_model_id += 1
00104             else:
00105                 # no explicit model column; initialize single model
00106                 structure_builder.init_model(current_model_id)
00107             if current_chain_id!=chainid:
00108                 current_chain_id=chainid
00109                 structure_builder.init_chain(current_chain_id)
00110                 current_residue_id=resseq
00111                 icode, int_resseq=self._get_icode(resseq)
00112                 structure_builder.init_residue(resname, hetatm_flag, int_resseq, 
00113                     icode)
00114             elif current_residue_id!=resseq:
00115                 current_residue_id=resseq
00116                 icode, int_resseq=self._get_icode(resseq)
00117                 structure_builder.init_residue(resname, hetatm_flag, int_resseq, 
00118                     icode)
00119             coord=numpy.array((x, y, z), 'f')  
00120             element = element_list[i] if element_list else None
00121             structure_builder.init_atom(name, coord, tempfactor, occupancy, altloc,
00122                 name, element=element)   
00123             if aniso_flag==1:
00124                 u=(aniso_u11[i], aniso_u12[i], aniso_u13[i],
00125                     aniso_u22[i], aniso_u23[i], aniso_u33[i])
00126                 mapped_anisou=map(float, u)
00127                 anisou_array=numpy.array(mapped_anisou, 'f')
00128                 structure_builder.set_anisou(anisou_array)
00129         # Now try to set the cell
00130         try:
00131             a=float(mmcif_dict["_cell.length_a"])
00132             b=float(mmcif_dict["_cell.length_b"])
00133             c=float(mmcif_dict["_cell.length_c"])
00134             alpha=float(mmcif_dict["_cell.angle_alpha"])
00135             beta=float(mmcif_dict["_cell.angle_beta"])
00136             gamma=float(mmcif_dict["_cell.angle_gamma"])
00137             cell=numpy.array((a, b, c, alpha, beta, gamma), 'f')
00138             spacegroup=mmcif_dict["_symmetry.space_group_name_H-M"]
00139             spacegroup=spacegroup[1:-1] # get rid of quotes!!
00140             if spacegroup==None:
00141                 raise Exception
00142             structure_builder.set_symmetry(spacegroup, cell)
00143         except:
00144             pass    # no cell found, so just ignore

Here is the call graph for this function:

def Bio.PDB.MMCIFParser.MMCIFParser._get_icode (   self,
  resseq 
) [private]
Tries to return the icode. In MMCIF files this is just part of
resseq! In PDB files, it's a separate field.

Definition at line 145 of file MMCIFParser.py.

00145 
00146     def _get_icode(self, resseq):           
00147         """Tries to return the icode. In MMCIF files this is just part of
00148         resseq! In PDB files, it's a separate field."""
00149         last_resseq_char=resseq[-1]
00150         if last_resseq_char in ascii_letters:
00151             icode=last_resseq_char
00152             int_resseq=int(resseq[0:-1])
00153         else:
00154             icode=" "
00155             int_resseq=int(resseq)
00156         return icode, int_resseq    
00157 

Here is the caller graph for this function:

def Bio.PDB.MMCIFParser.MMCIFParser.get_structure (   self,
  structure_id,
  filename 
)

Definition at line 19 of file MMCIFParser.py.

00019 
00020     def get_structure(self, structure_id, filename):
00021         self._mmcif_dict=MMCIF2Dict(filename)
00022         self._structure_builder=StructureBuilder()
00023         self._build_structure(structure_id)
00024         return self._structure_builder.get_structure()


Member Data Documentation

Definition at line 20 of file MMCIFParser.py.

Definition at line 21 of file MMCIFParser.py.


The documentation for this class was generated from the following file: