def readrpSBMLtar(inputTar): rpsbml_paths = {} with tarfile.open(inputTar) as tar: for member in tar.getmembers(): rpsbml_paths[member.name] = rpRanker.rpSBML( member.name, libsbml.readSBMLFromString( tar.extractfile(member).read().decode("utf-8"))) return rpsbml_paths
return rpsbml_paths if __name__ == "__main__": parser = argparse.ArgumentParser( 'Given an SBML model and the generated SBML heterologous pathway by RetroPath2.0, merge the two' ) parser.add_argument('-inModel', type=str) parser.add_argument('-inSBMLtar', type=str) parser.add_argument('-outSBMLtar', type=str) params = parser.parse_args() #sbml read the different mode rpsbml_paths = readrpSBMLtar(params.inSBMLtar) for rpsbml_name in rpsbml_paths: #read the input sbml model input_rpsbml = rpRanker.rpSBML('inputMergeModel') input_rpsbml.readSBML(params.inModel) rpsbml_paths[rpsbml_name].mergeModels(input_rpsbml.model) rpfba = rpRanker.rpFBA(input_rpsbml) rpfba.allObj() ##### pass FBA results to the original model #### groups = rpfba.rpsbml.model.getPlugin('groups') rp_pathway = groups.getGroup('rp_pathway') for member in rp_pathway.getListOfMembers(): reacFBA = rpfba.rpsbml.model.getReaction(member.getIdRef()) reacIN = rpsbml_paths[rpsbml_name].model.getReaction( member.getIdRef()) reacIN.setAnnotation(reacFBA.getAnnotation()) #rpsbml_paths[rpsbml_name] = rpsbml_paths[rpsbml_name] input_rpsbml = None writerpSBMLtar(rpsbml_paths, params.outSBMLtar)
#!/usr/bin/env python3 import argparse import sys sys.path.insert(0, '/home/') import rpRanker if __name__ == "__main__": parser = argparse.ArgumentParser( 'Generate the sink from a model SBML by specifying the compartment') parser.add_argument('-inSBML', type=str) parser.add_argument('-outSink', type=str) parser.add_argument('-compartmentId', type=str, default='MNXC3') #TODO: check that the compartmentId exists and return an error if not. Idea: print the list of available compartments if error is found params = parser.parse_args() rpsbml = rpRanker.rpSBML('tmp') rpsbml.readSBML(params.inSBML) rpreader = rpRanker.rpReader() rpreader.genSink(rpsbml, params.outSink, params.compartmentId) exit(0)