def main(rdir, eqnfn, molfn, outfn): print ("Loading molecule names... ") # dictionary where keys are mol ids (C00001) and # items are names from second column of kegg-compounds file mol2name = common.parse_molecule_names(molfn) print "Loading reconstruction: %s/%s" % (rdir, common.NETWORK_REACTION_FILE) f = open("%s/%s" % (rdir, common.NETWORK_REACTION_FILE)) bf = open(eqnfn) reco = common.read_reconstruction(f) eqns = read_balanced_reactions(bf) print "%d reactions" % (len(reco)) write_matrix(reco, eqns, mol2name, outfn)
def main(rdir, eqnfn, molfn, taxon, modelid, modelname, species, outfn, sbmlversion, boundsfile, rxnnamefile=None, pathwayfile=None): print("Loading molecule names... ") # dictionary where keys are mol ids (C00001) and # items are names from second column of kegg-compounds file mol2name = common.parse_molecule_names(molfn) print "Loading reconstruction: %s/%s" % (rdir, common.NETWORK_REACTION_FILE) f = open("%s/%s" % (rdir, common.NETWORK_REACTION_FILE)) bf = open(eqnfn) reco = common.read_reconstruction(f) eqns = read_balanced_reactions(bf) if pathwayfile is not None: fp = open(pathwayfile) pathways={}; pathwayasnames={}; for s in fp: #print s sisalto = s.strip().split("\t") #print len(sisalto) if len(sisalto)>1: pathways[sisalto[0]]=sisalto[1] if len(sisalto)>2: pathwayasnames[sisalto[0]]=sisalto[2] if len(pathwayasnames) == 0: pathwayasnames = None else: pathways = None if rxnnamefile is not None: fp = open(rxnnamefile) rxnnames={}; for s in fp: sisalto = s.strip().split("\t") if len(sisalto)>1: rxnnames[sisalto[0]]=sisalto[1] #print ("rxnnames[%s] = %s" % (sisalto[0],sisalto[1])) else: rxnnames = None bounds={}; if boundsfile is not None: fp = open(boundsfile) for s in fp: sisalto = s.strip().split("\t") if len(sisalto)>1: bounds[sisalto[0].strip()]=sisalto[3] +","+ sisalto[4] # print "%d reactions" % (len(reco)) sbml = convert_to_SBML(reco, eqns, mol2name, taxon, modelid, modelname, species, sbmlversion, bounds, rxnnames, pathways, pathwayasnames) libsbml.writeSBMLToFile(sbml, outfn)