diff get_infos.py @ 1:ceffb29b60c9 draft

planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
author tduigou
date Mon, 03 Apr 2023 09:18:22 +0000
parents
children fa893f77dc22
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/get_infos.py	Mon Apr 03 09:18:22 2023 +0000
@@ -0,0 +1,44 @@
+from argparse import ArgumentParser
+from libsbml import (
+    readSBMLFromFile
+)
+
+
+def entry_point():
+    parser = ArgumentParser('Returns cell informations')
+    parser.add_argument(
+        'infile',
+        type=str,
+        help='SBML input file (xml)'
+    )
+    parser.add_argument(
+        '--comp',
+        type=str,
+        help='Path to store cell compartments'
+    )
+    parser.add_argument(
+        '--biomass',
+        type=str,
+        help='Path to store biomass reaction ID'
+    )
+    params = parser.parse_args()
+
+    sbml_doc = readSBMLFromFile(params.infile)
+
+    if params.comp:
+        compartments = sbml_doc.getModel().getListOfCompartments()
+        with open(params.comp, 'w') as f:
+            f.write('#ID\tNAME\n')
+            for comp in compartments:
+                f.write(f'{comp.getId()}\t{comp.getName()}\n')
+
+    if params.biomass:
+        reactions = sbml_doc.getModel().getListOfReactions()
+        with open(params.biomass, 'w') as f:
+            f.write('#ID\n')
+            for rxn in reactions:
+                if 'biomass' in rxn.getId().lower():
+                    f.write(f'{rxn.getId()}\n')
+
+if __name__ == "__main__":
+    entry_point()
\ No newline at end of file