Mercurial > repos > tduigou > get_sbml_model
comparison get_infos.py @ 12:1aadcfdae10b draft
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 94f89a44e330ccfccc8d94b5e7acf583c9d39343
author | tduigou |
---|---|
date | Tue, 01 Apr 2025 10:00:10 +0000 |
parents | 062f51695ae0 |
children | 6bcd8f09158d |
comparison
equal
deleted
inserted
replaced
11:062f51695ae0 | 12:1aadcfdae10b |
---|---|
39 | 39 |
40 | 40 |
41 def args(): | 41 def args(): |
42 parser = ArgumentParser("Returns cell informations") | 42 parser = ArgumentParser("Returns cell informations") |
43 parser.add_argument("infile", type=str, help="SBML input file (xml)") | 43 parser.add_argument("infile", type=str, help="SBML input file (xml)") |
44 parser.add_argument("--biomassid", type=str, help="ID of biomass reaction") | 44 parser.add_argument("--hostname-or-id", type=str, help="Hostname or model ID") |
45 parser.add_argument("--taxonid", type=str, help="Taxonomy ID") | 45 parser.add_argument("--comp", type=str, help="Path to store cell compartments") |
46 parser.add_argument("--standalone", action="store_true", help="Standalone mode, e.g. do not retrieve taxonomy ID on Internet (true if --taxonid is provided)") | 46 parser.add_argument("--biomass", type=str, help="Path to store biomass reaction ID") |
47 parser.add_argument("--compartments-outfile", type=str, help="Path to store cell compartments") | 47 parser.add_argument("--biomass-id", type=str, help="ID of biomass reaction") |
48 parser.add_argument("--biomassid-outfile", type=str, help="Path to store biomass reaction ID") | 48 parser.add_argument("--taxid", type=str, help="Path to store host taxonomy ID") |
49 parser.add_argument("--taxonid-outfile", type=str, help="Path to store host taxonomy ID") | |
50 params = parser.parse_args() | 49 params = parser.parse_args() |
51 return params | 50 return params |
52 | 51 |
53 | 52 |
54 def get_organism_from_bigg_model(model_id): | 53 def get_organism_from_bigg_model(model_id): |
95 for comp in compartments: | 94 for comp in compartments: |
96 comp_str += f"{comp.getId()}\t{comp.getName()}\n" | 95 comp_str += f"{comp.getId()}\t{comp.getName()}\n" |
97 print("Compartments:") | 96 print("Compartments:") |
98 for comp in compartments: | 97 for comp in compartments: |
99 print(f"{comp.getId()}\t{comp.getName()}".replace("\n", " | ")) | 98 print(f"{comp.getId()}\t{comp.getName()}".replace("\n", " | ")) |
100 if params.compartments_outfile: | 99 if params.comp: |
101 with open(params.compartments_outfile, "w") as f: | 100 with open(params.comp, "w") as f: |
102 f.write("#ID\tNAME\n") | 101 f.write("#ID\tNAME\n") |
103 f.write(comp_str) | 102 f.write(comp_str) |
104 | 103 |
105 if params.biomassid: | 104 if params.biomass_id: |
106 biomass_rxn = sbml_doc.getModel().getReaction(params.biomassid) | 105 biomass_rxn = sbml_doc.getModel().getReaction(params.biomass_id) |
107 else: | 106 else: |
108 biomass_rxn = get_biomass_rxn(sbml_doc) | 107 biomass_rxn = get_biomass_rxn(sbml_doc) |
109 if not biomass_rxn: | 108 if not biomass_rxn: |
110 print("Warning: unable to retrieve biomass reaction") | 109 print("Warning: unable to retrieve biomass reaction") |
111 biomass_id = "" | 110 biomass_id = "" |
112 else: | 111 else: |
113 biomass_id = biomass_rxn.getId() | 112 biomass_id = biomass_rxn.getId() |
114 print(f"Biomass reaction ID: {biomass_id}") | 113 print(f"Biomass reaction ID: {biomass_id}") |
115 if params.biomassid_outfile: | 114 if params.biomass: |
116 with open(params.biomassid_outfile, "w") as f: | 115 with open(params.biomass, "w") as f: |
117 f.write("#ID\n") | 116 f.write("#ID\n") |
118 f.write(f"{biomass_id}\n") | 117 f.write(f"{biomass_id}\n") |
119 | 118 |
120 if params.taxonid: | 119 if params.hostname_or_id: |
121 taxid = params.taxonid | 120 taxid = get_taxon_id(params.hostname_or_id) |
122 elif params.standalone: | |
123 taxid = -1 | |
124 else: | 121 else: |
125 model_id = sbml_doc.getModel().getId() | 122 model_id = sbml_doc.getModel().getId() |
123 taxid = -1 | |
126 if model_id: | 124 if model_id: |
127 taxid = get_taxon_id(sbml_doc.getModel().getId()) | 125 taxid = get_taxon_id(sbml_doc.getModel().getId()) |
128 if taxid == -1: | 126 if taxid == -1: |
129 # Try with model name | 127 # Try with model name |
130 model_name = sbml_doc.getModel().getName() | 128 model_name = sbml_doc.getModel().getName() |
131 if model_name: | 129 if model_name: |
132 taxid = get_taxon_id(sbml_doc.getModel().getName()) | 130 taxid = get_taxon_id(sbml_doc.getModel().getName()) |
133 print(f"Taxonomy ID: {taxid}") | 131 print(f"Taxonomy ID: {taxid}") |
134 | 132 |
135 if params.taxonid_outfile: | 133 if params.taxid: |
136 with open(params.taxonid_outfile, "w") as f: | 134 with open(params.taxid, "w") as f: |
137 f.write("#ID\n") | 135 f.write("#ID\n") |
138 f.write(f"{taxid}\n") | 136 f.write(f"{taxid}\n") |
139 | 137 |
140 | 138 |
141 if __name__ == "__main__": | 139 if __name__ == "__main__": |