Пример #1
0
    def parse_atoms(self):
        '''All ATOM lines are parsed even though only one per residue needs to be parsed. The reason for parsing all the
           lines is just to sanity-checks that the ATOMs within one residue are consistent with each other.'''

        atom_site_header_tag = self.main_tag.getElementsByTagName("PDBx:atom_siteCategory")
        assert(len(atom_site_header_tag) == 1)
        atom_site_header_tag = atom_site_header_tag[0]

        atom_site_tags = atom_site_header_tag.getElementsByTagName("PDBx:atom_site")

        residue_map = {}
        residues_read = {}
        int_type = types.IntType
        for t in atom_site_tags:
            r, seqres, ResidueAA, Residue3AA = PDBML_slow.parse_atom_site(t, self.modified_residues)
            if r:
                # skip certain ACE residues
                if not(self.pdb_id in cases_with_ACE_residues_we_can_ignore and Residue3AA == 'ACE'):
                    full_residue_id = str(r)
                    if residues_read.get(full_residue_id):
                        assert(residues_read[full_residue_id] == (r.ResidueAA, seqres))
                    else:
                        residues_read[full_residue_id] = (r.ResidueAA, seqres)
                        residue_map[r.Chain] = residue_map.get(r.Chain, {})
                        assert(type(seqres) == int_type)
                        residue_map[r.Chain][str(r)] = seqres

        ## Create SequenceMap objects to map the ATOM Sequences to the SEQRES Sequences
        atom_to_seqres_sequence_maps = {}
        for chain_id, atom_seqres_mapping in residue_map.iteritems():
            atom_to_seqres_sequence_maps[chain_id] = SequenceMap.from_dict(atom_seqres_mapping)

        self.atom_to_seqres_sequence_maps = atom_to_seqres_sequence_maps
Пример #2
0
    def end_element(self, name):
        tag_content = ("".join(self.tag_data)).strip()

        if self._BLOCK != None:
            handler = self._end_handlers.get(self._BLOCK)
            if handler:
                handler(name, tag_content)

        if name == 'PDBx:atom_site' or name == "PDBx:pdbx_database_PDB_obs_sprCategory":
            self._BLOCK = None

        elif name == 'PDBx:atom_siteCategory':
            self.in_atom_sites_block = False
            ## Create SequenceMap objects to map the ATOM Sequences to the SEQRES Sequences
            atom_to_seqres_sequence_maps = {}
            for chain_id, atom_seqres_mapping in self._residue_map.iteritems():
                atom_to_seqres_sequence_maps[chain_id] = SequenceMap.from_dict(atom_seqres_mapping)
            self.atom_to_seqres_sequence_maps = atom_to_seqres_sequence_maps