示例#1
0
 def CreateEmptyGroupDecomposition(self) -> GroupDecomposition:
     """Create and empty group decomposition object."""
     emptymol = Molecule.FromSmiles("")
     decomposition = self.Decompose(
         emptymol, ignore_protonations=True, raise_exception=False
     )
     for i, (group, _) in enumerate(decomposition.groups):
         decomposition.groups[i] = (group, [])
     return decomposition
示例#2
0
                                          mol_formula):
                if count == '':
                    count = 1
                else:
                    count = int(count)
                atom_bag[atom] = atom_bag.get(atom, 0) + count * times

    n_protons = sum([
        c * periodic_table.GetAtomicNumber(str(elem))
        for (elem, c) in atom_bag.items()
    ])
    atom_bag['e-'] = n_protons - formal_charge

    return atom_bag, formal_charge


if __name__ == "__main__":
    logging.getLogger().setLevel(logging.WARNING)
    from molecule import Molecule
    compound_list = [
        ('D-Erythrulose',
         'InChI=1S/C4H8O4/c5-1-3(7)4(8)2-6/h3,5-7H,1-2H2/t3-/m1/s1')
    ]

    for name, inchi in compound_list:
        print("Formula: %s\nCharge: %d" % GetFormulaAndCharge(inchi))
        diss_table, major_ms = GetDissociationConstants(inchi)
        m = Molecule.FromSmiles(major_ms)
        print("Name: %s\nInChI: %s\npKas: %s" %
              (name, m.ToInChI(), str(diss_table)))