Mercurial > repos > tduigou > get_sbml_model
comparison get_infos.py @ 7:8dc4d3964ab5 draft
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 09fcdb371be214b222a2e1c540d7c6e7489ca258
| author | tduigou |
|---|---|
| date | Mon, 04 Sep 2023 14:19:43 +0000 |
| parents | 1482291aaa5c |
| children | 768ed7cc0978 |
comparison
equal
deleted
inserted
replaced
| 6:9b5947d48192 | 7:8dc4d3964ab5 |
|---|---|
| 9 parser = ArgumentParser('Returns cell informations') | 9 parser = ArgumentParser('Returns cell informations') |
| 10 parser.add_argument( | 10 parser.add_argument( |
| 11 'infile', | 11 'infile', |
| 12 type=str, | 12 type=str, |
| 13 help='SBML input file (xml)' | 13 help='SBML input file (xml)' |
| 14 ) | |
| 15 # argument to tag file from BiGG | |
| 16 parser.add_argument( | |
| 17 '--bigg', | |
| 18 action='store_true', | |
| 19 help='Tag file from BiGG' | |
| 14 ) | 20 ) |
| 15 parser.add_argument( | 21 parser.add_argument( |
| 16 '--comp', | 22 '--comp', |
| 17 type=str, | 23 type=str, |
| 18 help='Path to store cell compartments' | 24 help='Path to store cell compartments' |
| 50 for rxn in reactions: | 56 for rxn in reactions: |
| 51 if 'biomass' in rxn.getId().lower(): | 57 if 'biomass' in rxn.getId().lower(): |
| 52 f.write(f'{rxn.getId()}\n') | 58 f.write(f'{rxn.getId()}\n') |
| 53 | 59 |
| 54 if params.taxid: | 60 if params.taxid: |
| 55 # Extended Name | 61 hostname = '' |
| 56 server = 'http://bigg.ucsd.edu/api/v2/models/' | 62 |
| 57 ext = params.hostid | 63 # Model from BiGG |
| 58 r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) | 64 if params.bigg: |
| 59 if not r.ok: | 65 # Extended Name |
| 60 print(f"Warning: unable to retrieve host name for id {params.hostid}") | 66 server = 'http://bigg.ucsd.edu/api/v2/models/' |
| 61 else: | 67 ext = params.hostid |
| 62 try: | |
| 63 hostname = r.json()["organism"] | |
| 64 except KeyError: | |
| 65 print(f"Warning: unable to retrieve host name for id {params.hostid}") | |
| 66 hostname = '' | |
| 67 if not hostname: | |
| 68 taxid = '' | |
| 69 else: | |
| 70 # TAXON ID | |
| 71 server = 'https://rest.ensembl.org' | |
| 72 ext = f'/taxonomy/id/{hostname}?' | |
| 73 r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) | 68 r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) |
| 74 if not r.ok: | 69 if not r.ok: |
| 75 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") | 70 print(f"Warning: unable to retrieve host name for id {params.hostid}") |
| 76 else: | 71 else: |
| 77 try: | 72 try: |
| 78 taxid = r.json()["id"] | 73 hostname = r.json()["organism"] |
| 79 except KeyError: | 74 except KeyError: |
| 75 print(f"Warning: unable to retrieve host name for id {params.hostid}") | |
| 76 if not hostname: | |
| 77 taxid = '' | |
| 78 else: | |
| 79 # TAXON ID | |
| 80 server = 'https://rest.ensembl.org' | |
| 81 ext = f'/taxonomy/id/{hostname}?' | |
| 82 r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) | |
| 83 if not r.ok: | |
| 80 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") | 84 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") |
| 81 taxid = '' | 85 else: |
| 86 try: | |
| 87 taxid = r.json()["id"] | |
| 88 except KeyError: | |
| 89 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") | |
| 90 taxid = '' | |
| 91 | |
| 92 # Model from user | |
| 93 else: | |
| 94 taxid = params.hostid | |
| 95 | |
| 82 with open(params.taxid, 'w') as f: | 96 with open(params.taxid, 'w') as f: |
| 83 f.write('#ID\n') | 97 f.write('#ID\n') |
| 84 f.write(f'{taxid}\n') | 98 f.write(f'{taxid}\n') |
| 85 | 99 |
| 86 | 100 |
