Mercurial > repos > tduigou > get_sbml_model
annotate get_infos.py @ 9:6a2871e89352 draft default tip
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
author | tduigou |
---|---|
date | Wed, 14 Feb 2024 15:25:38 +0000 |
parents | 768ed7cc0978 |
children |
rev | line source |
---|---|
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
1 from argparse import ArgumentParser |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
2 from libsbml import ( |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
3 readSBMLFromFile |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
4 ) |
9
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
5 from taxonid import get_taxonid |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
6 |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
7 |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
8 def get_biomass_rxn(sbml_doc): |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
9 ''' |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
10 Returns the biomass reaction of the model |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
11 |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
12 Parameters |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
13 ---------- |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
14 sbml_doc: libsbml.SBMLDocument |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
15 SBML model |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
16 |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
17 Returns |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
18 ------- |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
19 biomass_rxn: libsbml.Reaction |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
20 Biomass reaction |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
21 ''' |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
22 reactions = sbml_doc.getModel().getListOfReactions() |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
23 # Search for 'biomass' keyword in reaction name |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
24 for rxn in reactions: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
25 if 'biomass' in rxn.getName().lower(): |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
26 return rxn |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
27 # Search for 'biomass' keyword in products |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
28 # AND not in reactants |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
29 for rxn in reactions: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
30 in_reactants = False |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
31 for reac in rxn.getListOfReactants(): |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
32 if 'biomass' in reac.getSpecies().lower(): |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
33 in_reactants = True |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
34 break |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
35 if not in_reactants: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
36 for prod in rxn.getListOfProducts(): |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
37 if 'biomass' in prod.getSpecies().lower(): |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
38 return rxn |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
39 return None |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
40 |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
41 |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
42 def args(): |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
43 parser = ArgumentParser('Returns cell informations') |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
44 parser.add_argument( |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
45 'infile', |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
46 type=str, |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
47 help='SBML input file (xml)' |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
48 ) |
7
8dc4d3964ab5
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 09fcdb371be214b222a2e1c540d7c6e7489ca258
tduigou
parents:
4
diff
changeset
|
49 # argument to tag file from BiGG |
8dc4d3964ab5
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 09fcdb371be214b222a2e1c540d7c6e7489ca258
tduigou
parents:
4
diff
changeset
|
50 parser.add_argument( |
8dc4d3964ab5
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 09fcdb371be214b222a2e1c540d7c6e7489ca258
tduigou
parents:
4
diff
changeset
|
51 '--bigg', |
8dc4d3964ab5
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 09fcdb371be214b222a2e1c540d7c6e7489ca258
tduigou
parents:
4
diff
changeset
|
52 action='store_true', |
8dc4d3964ab5
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 09fcdb371be214b222a2e1c540d7c6e7489ca258
tduigou
parents:
4
diff
changeset
|
53 help='Tag file from BiGG' |
8dc4d3964ab5
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 09fcdb371be214b222a2e1c540d7c6e7489ca258
tduigou
parents:
4
diff
changeset
|
54 ) |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
55 parser.add_argument( |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
56 '--comp', |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
57 type=str, |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
58 help='Path to store cell compartments' |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
59 ) |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
60 parser.add_argument( |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
61 '--biomass', |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
62 type=str, |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
63 help='Path to store biomass reaction ID' |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
64 ) |
2
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
65 parser.add_argument( |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
66 '--biomass-id', |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
67 type=str, |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
68 help='ID of biomass reaction' |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
69 ) |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
70 parser.add_argument( |
9
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
71 '--hostname', |
2
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
72 type=str, |
9
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
73 help='Name of the host organism' |
2
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
74 ) |
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
75 parser.add_argument( |
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
76 '--taxid', |
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
77 type=str, |
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
78 help='Path to store host taxonomy ID' |
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
79 ) |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
80 params = parser.parse_args() |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
81 return params |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
82 |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
83 |
9
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
84 def get_taxon_id(hostid: str, bigg: bool): |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
85 ''' |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
86 Returns the taxonomy ID of the host organism |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
87 |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
88 Parameters |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
89 ---------- |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
90 hostid: str |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
91 Extended name of the host organism or host ID if from BiGG |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
92 bigg: bool |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
93 True if the model is from BiGG |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
94 |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
95 Returns |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
96 ------- |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
97 taxid: str |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
98 Taxonomy ID of the host organism |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
99 ''' |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
100 if not bigg: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
101 return get_taxonid(hostid) |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
102 |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
103 hostname = '' |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
104 # Extended Name |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
105 server = 'http://bigg.ucsd.edu/api/v2/models/' |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
106 ext = hostid |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
107 r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
108 if not r.ok: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
109 print(f"Warning: unable to retrieve host name for id {hostid}") |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
110 else: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
111 try: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
112 hostname = r.json()["organism"] |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
113 except KeyError: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
114 print(f"Warning: unable to retrieve host name for id {hostid}") |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
115 if not hostname: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
116 taxid = '' |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
117 else: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
118 # TAXON ID |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
119 server = 'https://rest.ensembl.org' |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
120 ext = f'/taxonomy/id/{hostname}?' |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
121 r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
122 if not r.ok: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
123 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
124 else: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
125 try: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
126 taxid = r.json()["id"] |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
127 except KeyError: |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
128 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
129 taxid = '' |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
130 return taxid |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
131 |
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
132 |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
133 def entry_point(): |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
134 |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
135 params = args() |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
136 |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
137 sbml_doc = readSBMLFromFile(params.infile) |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
138 |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
139 compartments = sbml_doc.getModel().getListOfCompartments() |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
140 comp_str = '' |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
141 for comp in compartments: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
142 comp_str += f'{comp.getId()}\t{comp.getName()}\n' |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
143 if params.comp: |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
144 with open(params.comp, 'w') as f: |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
145 f.write('#ID\tNAME\n') |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
146 f.write(comp_str) |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
147 else: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
148 print('Compartments:') |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
149 for comp in compartments: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
150 print(f'{comp.getId()}\t{comp.getName()}'.replace('\n', ' | ')) |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
151 |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
152 if params.biomass_id: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
153 biomass_rxn = sbml_doc.getModel().getReaction(params.biomass_id) |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
154 else: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
155 biomass_rxn = get_biomass_rxn(sbml_doc) |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
156 if not biomass_rxn: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
157 print('Warning: unable to retrieve biomass reaction') |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
158 biomass_id = '' |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
159 else: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
160 biomass_id = biomass_rxn.getId() |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
161 if params.biomass: |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
162 with open(params.biomass, 'w') as f: |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
163 f.write('#ID\n') |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
164 f.write(f'{biomass_id}\n') |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
165 else: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
166 print(f'Biomass reaction ID: {biomass_id}') |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
167 |
9
6a2871e89352
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b
tduigou
parents:
8
diff
changeset
|
168 taxid = get_taxon_id(params.hostname, params.bigg) |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
169 |
2
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
170 if params.taxid: |
4
1482291aaa5c
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 4a0b08beb8cdf51ab295a1f5f8c586d6bbaf5586
tduigou
parents:
2
diff
changeset
|
171 with open(params.taxid, 'w') as f: |
1482291aaa5c
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 4a0b08beb8cdf51ab295a1f5f8c586d6bbaf5586
tduigou
parents:
2
diff
changeset
|
172 f.write('#ID\n') |
1482291aaa5c
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 4a0b08beb8cdf51ab295a1f5f8c586d6bbaf5586
tduigou
parents:
2
diff
changeset
|
173 f.write(f'{taxid}\n') |
8
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
174 else: |
768ed7cc0978
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit aa5a9ac47997d9c1718b9c7eaff1b83c63ac1d58
tduigou
parents:
7
diff
changeset
|
175 print(f'Taxonomy ID: {taxid}') |
2
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
176 |
fa893f77dc22
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 18fcec17fb6415ad5a59b9bcfa853e755c768e6f
tduigou
parents:
1
diff
changeset
|
177 |
1
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
178 if __name__ == "__main__": |
ceffb29b60c9
planemo upload commit 9c19f737cd6e2152151c8bf97a53ab1afe51a4a0
tduigou
parents:
diff
changeset
|
179 entry_point() |