Mercurial > repos > tduigou > get_sbml_model
comparison get_infos.py @ 1:ceffb29b60c9 draft
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
author | tduigou |
---|---|
date | Mon, 03 Apr 2023 09:18:22 +0000 |
parents | |
children | fa893f77dc22 |
comparison
equal
deleted
inserted
replaced
0:4797d0b36ff3 | 1:ceffb29b60c9 |
---|---|
1 from argparse import ArgumentParser | |
2 from libsbml import ( | |
3 readSBMLFromFile | |
4 ) | |
5 | |
6 | |
7 def entry_point(): | |
8 parser = ArgumentParser('Returns cell informations') | |
9 parser.add_argument( | |
10 'infile', | |
11 type=str, | |
12 help='SBML input file (xml)' | |
13 ) | |
14 parser.add_argument( | |
15 '--comp', | |
16 type=str, | |
17 help='Path to store cell compartments' | |
18 ) | |
19 parser.add_argument( | |
20 '--biomass', | |
21 type=str, | |
22 help='Path to store biomass reaction ID' | |
23 ) | |
24 params = parser.parse_args() | |
25 | |
26 sbml_doc = readSBMLFromFile(params.infile) | |
27 | |
28 if params.comp: | |
29 compartments = sbml_doc.getModel().getListOfCompartments() | |
30 with open(params.comp, 'w') as f: | |
31 f.write('#ID\tNAME\n') | |
32 for comp in compartments: | |
33 f.write(f'{comp.getId()}\t{comp.getName()}\n') | |
34 | |
35 if params.biomass: | |
36 reactions = sbml_doc.getModel().getListOfReactions() | |
37 with open(params.biomass, 'w') as f: | |
38 f.write('#ID\n') | |
39 for rxn in reactions: | |
40 if 'biomass' in rxn.getId().lower(): | |
41 f.write(f'{rxn.getId()}\n') | |
42 | |
43 if __name__ == "__main__": | |
44 entry_point() |