Пример #1
0
def add_thermodynamics(cursor):
    from groups import GroupMissingTrainDataError, GroupDecompositionError

    gc = GroupContribution(sqlite_name="gibbs.sqlite", html_name="pathologic")
    gc.init()

    cursor.execute("DROP TABLE IF EXISTS yeast_inchi2thermo")
    cursor.execute(
        "CREATE TABLE yeast_inchi2thermo (inchi TEXT, charge INT, nH INT, dG0_f REAL)"
    )
    cursor.execute("DROP INDEX IF EXISTS yeast_inchi2thermo_idx")
    cursor.execute(
        "CREATE INDEX yeast_inchi2thermo_idx ON yeast_inchi2thermo (inchi);")

    inchi_list = []
    for row in cursor.execute("SELECT distinct(inchi) " \
                              "FROM yeast_species2inchi WHERE inchi IS NOT NULL"):
        inchi = row[0]
        inchi_list.append(str(inchi))

    for inchi in inchi_list:
        try:
            mol = Molecule.FromInChI(str(inchi))
            pmap = gc.Mol2PseudoisomerMap(mol)
            for ((z, nH), dG0) in pmap.iteritems():
                cursor.execute(
                    "INSERT INTO yeast_inchi2thermo VALUES(?,?,?,?)",
                    [inchi, z, nH, dG0])
        except (IOError, GroupMissingTrainDataError, GroupDecompositionError):
            sys.stderr.write(
                "Cannot convert the following InChI to a pybel Molecule")
Пример #2
0
 def SetInChI(self, inchi):
     if inchi == None:
         self.inchi = None
         self.mol = None
         self.formula = None
         self.mass = None
     else:
         self.inchi = inchi
         self.mol = Molecule.FromInChI(inchi)
         self.formula = self.mol.GetFormula()
         self.mass = self.mol.GetExactMass()
    def EstimateInChI(self, inchi):
        mol = Molecule.FromInChI(inchi)
        #mol.RemoveHydrogens()
        decomposition = self.group_decomposer.Decompose(
            mol, ignore_protonations=False, strict=True)

        nH = decomposition.Hydrogens()
        charge = decomposition.NetCharge()
        nMg = decomposition.Magnesiums()
        groupvec = decomposition.AsVector()
        dG0, ker = self.EstimateGroupVector(groupvec)
        return dG0, nH, charge, nMg, ker
Пример #4
0
    def get_nH_and_charge(self):
        if not self.mol and self.inchi:
            self.mol = Molecule.FromInChI(self.inchi)

        if self.mol:
            return self.mol.GetHydrogensAndCharge()

        # if there is no InChI assume that self.formula is correct and that
        # it represents the number of H for the neutral species
        atom_bag = self.get_atom_bag()
        if not atom_bag:
            return None
        return atom_bag.get('H', 0), 0
Пример #5
0
    def GetMolecule(self):
        """Gets a Molecule for this compound if possible.
        
        Returns None if no molecular data is available.
        """
        if self.mol:
            return self.mol

        if self.inchi:
            self.mol = Molecule.FromInChI(self.inchi)
            self.mol.SetTitle(self.name)
            return self.mol

        raise kegg_errors.KeggParseException(
            "C%05d (%s) doesn't have an explicit molecular structure" %
            (self.cid, self.name))