Previous changeset 6:9b5947d48192 (2023-08-28) Next changeset 8:768ed7cc0978 (2023-09-29) |
Commit message:
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 09fcdb371be214b222a2e1c540d7c6e7489ca258 |
modified:
get_infos.py get_sbml_model.xml |
b |
diff -r 9b5947d48192 -r 8dc4d3964ab5 get_infos.py --- a/get_infos.py Mon Aug 28 14:24:48 2023 +0000 +++ b/get_infos.py Mon Sep 04 14:19:43 2023 +0000 |
[ |
@@ -12,6 +12,12 @@ type=str, help='SBML input file (xml)' ) + # argument to tag file from BiGG + parser.add_argument( + '--bigg', + action='store_true', + help='Tag file from BiGG' + ) parser.add_argument( '--comp', type=str, @@ -52,33 +58,41 @@ f.write(f'{rxn.getId()}\n') if params.taxid: - # Extended Name - server = 'http://bigg.ucsd.edu/api/v2/models/' - ext = params.hostid - r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) - if not r.ok: - print(f"Warning: unable to retrieve host name for id {params.hostid}") - else: - try: - hostname = r.json()["organism"] - except KeyError: - print(f"Warning: unable to retrieve host name for id {params.hostid}") - hostname = '' - if not hostname: - taxid = '' - else: - # TAXON ID - server = 'https://rest.ensembl.org' - ext = f'/taxonomy/id/{hostname}?' + hostname = '' + + # Model from BiGG + if params.bigg: + # Extended Name + server = 'http://bigg.ucsd.edu/api/v2/models/' + ext = params.hostid r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) if not r.ok: - print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") + print(f"Warning: unable to retrieve host name for id {params.hostid}") else: try: - taxid = r.json()["id"] + hostname = r.json()["organism"] except KeyError: + print(f"Warning: unable to retrieve host name for id {params.hostid}") + if not hostname: + taxid = '' + else: + # TAXON ID + server = 'https://rest.ensembl.org' + ext = f'/taxonomy/id/{hostname}?' + r = r_get(server+ext, headers={ "Content-Type" : "application/json"}) + if not r.ok: print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") - taxid = '' + else: + try: + taxid = r.json()["id"] + except KeyError: + print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") + taxid = '' + + # Model from user + else: + taxid = params.hostid + with open(params.taxid, 'w') as f: f.write('#ID\n') f.write(f'{taxid}\n') |
b |
diff -r 9b5947d48192 -r 8dc4d3964ab5 get_sbml_model.xml --- a/get_sbml_model.xml Mon Aug 28 14:24:48 2023 +0000 +++ b/get_sbml_model.xml Mon Sep 04 14:19:43 2023 +0000 |
[ |
@@ -1,23 +1,32 @@ -<tool id="get_sbml_model" name="Pick SBML Model" version="0.0.4" profile="21.09" license="MIT"> +<tool id="get_sbml_model" name="Pick SBML Model" version="0.1.0" profile="21.09" license="MIT"> <description>Get an SBML model (BiGG)</description> <requirements> <requirement type="package" version="7.81.0">curl</requirement> <requirement type="package" version="1.11">gzip</requirement> <requirement type="package" version="5.19.2">python-libsbml</requirement> <requirement type="package" version="2.29">requests</requirement> + <requirement type="package" version="0.1.0">taxonid</requirement> </requirements> <command detect_errors="exit_code"><![CDATA[ #if str($cond_src.from_src) == 'from_bigg' curl -o - 'http://bigg.ucsd.edu/static/models/${cond_src.hostid}.xml.gz' | gunzip > '$model' && #else - cp '${cond_src.input_file}' '$model' && + python -m taxonid '${cond_src.hostname}' --output-file tmpfile && + echo "#ID" > '$taxid' && + cat tmpfile >> '$taxid' && #end if + echo "listdir:"; + ls; python '$__tool_directory__/'get_infos.py - '$model' - --hostid '${cond_src.hostid}' - --comp '$compartments' - --biomass '$biomass' - --taxid '$taxid' + #if str($cond_src.from_src) == 'from_bigg' + '$model' + --taxid '$taxid' + #else + '${cond_src.input_file}' + #end if + --hostid '${cond_src.hostid}' + --comp '$compartments' + --biomass '$biomass' ]]></command> <inputs> <conditional name="cond_src"> @@ -26,8 +35,11 @@ <option value="from_history">Select file from the History</option> </param> <when value="from_history"> + <param name="hostname" type="text" help="Fullname of the model"> + <validator type="empty_field" message="The fullname of the organism is required"/> + </param> <param name="hostid" type="text" help="ID of the model"> - <validator type="empty_field" message="An ID is required"/> + <validator type="empty_field" message="ID of the organism is required"/> </param> <param name="input_file" type="data" format="sbml,xml" label="SBML model" help="An SBML file is expected"/> </when> @@ -85,30 +97,30 @@ </conditional> </inputs> <outputs> - <data name="model" format="sbml" label="${cond_src.hostid}" /> + <data name="model" format="sbml" label="${cond_src.hostid}"> + <filter>cond_src['from_src'] == 'from_bigg'</filter> + </data> <data name="taxid" format="tsv" label="${cond_src.hostid} (taxon id)" /> <data name="compartments" format="tsv" label="${cond_src.hostid} (compartments)" /> <data name="biomass" format="tsv" label="${cond_src.hostid} (biomass reactions)" /> </outputs> <tests> <test> - <conditional name="cond_src"> - <param name="from_src" value="from_bigg" /> - <param name="hostid" value="iML1515" /> - </conditional> + <param name="from_src" value="from_bigg" /> + <param name="hostid" value="iML1515" /> <output name="model" md5="9bf81d20cab5476700697ded95b716d1" /> - <output name="taxid" md5="6b35ad8a1c2b640af4ba738c2f5f876e" /> + <output name="taxid" md5="7c62bd818057838b3557c8d87cca47fc" /> <output name="compartments" md5="e93a875a2d8efc10a880ae3ac0018236" /> <output name="biomass" md5="cffb2fbdb07d1301dfdb7bb284fb7e06" /> </test> <test> <conditional name="cond_src"> <param name="from_src" value="from_history" /> + <param name="hostname" value="Escherichia coli str. K-12 substr. MG1655" /> <param name="hostid" value="e_coli_core" /> <param name="input_file" value="e_coli_core.xml" /> </conditional> - <output name="model" md5="4574760460afe9e1b3388dc15f354706" /> - <output name="taxid" md5="6b35ad8a1c2b640af4ba738c2f5f876e" /> + <output name="taxid" md5="ee08b511771328e6254775a51779d421" /> <output name="compartments" md5="71dc18974a12e9bb75bb2c4cffd13edf" /> <output name="biomass" md5="d10baa335181450c7bffa9b4ca01754a" /> </test> |