예제 #1
0
 def _parse_fragment_tree(self, el):
     fragments = []
     for el_fragments in el.findall('fragments'):
         for el_f in el_fragments:
             fragments.append(self._parse_fragment_tree(el_f))
     atoms = []
     for el_atoms in el.findall('atoms'):
         for el_a in el_atoms:
             atom_classes = {"dummy": im.dummy,
                             "unknown": im.unknown,
                             "element": im.element}
             descr = atom_classes[el_a.get('type')](el_a.get('name'))
             atoms.append((el_a.get('label'),
                           im.atom(descr, int(el_a.get('nsites', '1')))))
     bonds = []
     for el_bonds in el.findall('bonds'):
         for el_b in el_bonds:
             a1, a2 = el_b.get('atoms').split()
             bonds.append((a1, a2, el_b.get('order')))
     label = el.get('label')
     species = el.get('species')
     polymer_type = el.get('polymer_type', None)
     if polymer_type is None:
         return label, im.fragment(species, fragments, atoms, bonds)
     else:
         assert len(atoms) == 0
         return label, im.polymer(species, fragments, bonds, polymer_type)
 def _make_molecule(self):
     C = M.element('C')
     H = M.element('H')
     N = M.element('N')
     O = M.element('O')
     peptide_group = M.fragment('peptide',
                                (),
                                (('CA', M.atom(C)),
                                 ('HA', M.atom(H)),
                                 ('H', M.atom(H)),
                                 ('N', M.atom(N)),
                                 ('C', M.atom(C)),
                                 ('O', M.atom(O))),
                                (('N', 'H', "single"),
                                 ('N', 'CA', "single"),
                                 ('CA', 'HA', "single"),
                                 ('CA', 'C', "single"),
                                 ('C', 'O', "double")))
     ala_sidechain = M.fragment('ala_sidechain',
                                (),
                                (('CB', M.atom(C)),
                                 ('HB1', M.atom(H)),
                                 ('HB2', M.atom(H)),
                                 ('HB3', M.atom(H))),
                                (('CB', 'HB1', "single"),
                                 ('CB', 'HB2', "single"),
                                 ('CB', 'HB3', "single"),))
     ala = M.fragment('alanine',
                      (('peptide', peptide_group),
                       ('sidechain', ala_sidechain)),
                      (),
                      (('peptide.CA', 'sidechain.CB', "single"),))
     return M.polymer('alanine_dipeptide',
                      (('ALA1', ala),
                       ('ALA2', ala)),
                      (('ALA1.peptide.C', 'ALA2.peptide.N', "single"),),
                      'polypeptide')