def __init__(self, sparse, arrow='<=>', rid=None):
     for cid, coeff in sparse.iteritems():
         if not (isinstance(coeff, float) or isinstance(coeff, int)):
             raise ValueError(
                 'All values in KeggReaction must be integers or floats')
     self.sparse = dict(filter(lambda (k, v): v, sparse.items()))
     self.arrow = arrow
     self.rid = rid
     self.ccache = CompoundCacher()
def main(fname, pH, I, T):
    ccache = CompoundCacher()
    for row in csv.reader(open(fname, 'r'), delimiter='\t'):
        compound_id = re.findall('(C[0-9]+)_10', row[0])[0]
        dG0 = float(row[1])
        comp = ccache.get_compound(compound_id)
        dG0_prime = dG0 + comp.transform_neutral(pH, I, T)
        print '%s\t%f\t%f' % (compound_id, dG0, dG0_prime)
    ccache.dump()
示例#3
0
def get_ddG0(rxn_dict, pH, I, novel_mets):
    ccache = CompoundCacher()
    # ddG0 = get_transform_ddG0(rxn_dict, ccache, pH, I, T)
    T = 298.15
    ddG0_forward = 0
    for compound_id, coeff in rxn_dict.items():
        if novel_mets != None and compound_id in novel_mets:
            comp = novel_mets[compound_id]
        else:
            comp = ccache.get_compound(compound_id)
        ddG0_forward += coeff * comp.transform_pH7(pH, I, T)

    return ddG0_forward
    def __init__(self, S, cids, rids=None):
        self.S = S
        self.cids = cids
        self.rids = rids
        assert len(self.cids) == self.S.shape[0]
        if self.rids is not None:
            assert len(self.rids) == self.S.shape[1]
        self.ccache = CompoundCacher()

        # remove H+ from the stoichiometric matrix if it exists
        if 'C00080' in self.cids:
            i = self.cids.index('C00080')
            self.S = np.vstack((self.S[:i, :], self.S[i + 1:, :]))
            self.cids.pop(i)
示例#5
0
# -*- coding: utf-8 -*-
"""
Created on Thu Aug  7 21:00:31 2014

@author: eladn
"""
import sys
from compound_cacher import CompoundCacher

compound_id = sys.argv[1]
CompoundCacher.RebuildCompoundJSON()
ccache = CompoundCacher()
sys.stderr.write('removing %s from cache ...\n' % compound_id)
ccache.remove(compound_id)
sys.stderr.write('recalculating SMILES and pKa values ...\n')
comp = ccache.get_compound(compound_id)
sys.stderr.write('writing new data to cache ...\n')
ccache.dump()

d = comp.to_json_dict()
sys.stderr.write(''.join(['%20s : %s\n' % (k, v) for (k, v) in d.iteritems()]))
示例#6
0
import sys

sys.path.append('../python')
import inchi2gv
from compound_cacher import CompoundCacher
from molecule import Molecule

#logger = logging.getLogger('')
#logger.setLevel(logging.DEBUG)
ccache = CompoundCacher('../cache/compounds.json')
groups_data = inchi2gv.init_groups_data()
group_list = groups_data.GetGroupNames()
group_names = groups_data.GetGroupNames()
decomposer = inchi2gv.InChIDecomposer(groups_data)

# test the decomposition of ATP into groups
ATP_inchi = ccache.get_compound('C00002').inchi
group_def = decomposer.inchi_to_groupvec(ATP_inchi)
for j, group_name in enumerate(group_names):
    if group_def[j] != 0:
        print group_name, ' x %d' % group_def[j]

patterns = ['c~[O;+0]', 'c~[O;+1]', 'c~[n;+1]~c', 'c~[n;+0]~c', 'c~[n;-1]~c']

for cid in ['C00255', 'C01007']:
    comp = ccache.get_compound(cid)
    print "-" * 50, '\n%s' % cid
    inchi = comp.inchi
    mol = Molecule.FromInChI(inchi)
    print mol.ToSmiles()
示例#7
0
                'phase': 'aqueous',
                'dG0_f': np.round(dG0_f, 2),
                'nH': nH,
                'z': z,
                'nMg': 0
            }
            yield d


if __name__ == '__main__':
    import sys, json
    logger = logging.getLogger('')
    logger.setLevel(logging.DEBUG)
    from compound_cacher import CompoundCacher, CompoundEncoder
    from molecule import Molecule, OpenBabelError
    ccache = CompoundCacher(cache_fname=None)

    for compound_id in ['C00087', 'C00282', 'C00237']:
        comp = Compound.from_kegg(compound_id)
        try:
            mol = Molecule.FromInChI(str(comp.inchi))
            sys.stderr.write(
                '%s : formula = %s, nE = %s' %
                (str(comp.inchi), mol.GetFormula(), mol.GetNumElectrons()))
        except OpenBabelError:
            pass
        ccache.add(comp)
        sys.stderr.write(
            '\ncompound id = %s, nH = %s, z = %s, pKa = %s, bag = %s\n\n\n' %
            (compound_id, str(comp.nHs), str(comp.zs), str(
                comp.pKas), str(comp.atom_bag)))
示例#8
0
def load_compound_cache():
    ccache = CompoundCacher()
    return ccache