Previous changeset 8:768ed7cc0978 (2023-09-29) |
Commit message:
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b |
modified:
get_infos.py get_sbml_model.xml |
b |
diff -r 768ed7cc0978 -r 6a2871e89352 get_infos.py --- a/get_infos.py Fri Sep 29 09:03:09 2023 +0000 +++ b/get_infos.py Wed Feb 14 15:25:38 2024 +0000 |
[ |
@@ -2,7 +2,7 @@ from libsbml import ( readSBMLFromFile ) -from requests import get as r_get +from taxonid import get_taxonid def get_biomass_rxn(sbml_doc): @@ -39,51 +39,6 @@ return None -def get_taxon_id(hostid): - ''' - Returns the taxonomy ID of the host organism - - Parameters - ---------- - hostid: str - Extended name of the host organism - - Returns - ------- - taxid: str - Taxonomy ID of the host organism - ''' - taxid = get_taxon_id(hostid) - hostname = '' - # Extended Name - server = 'http://bigg.ucsd.edu/api/v2/models/' - ext = 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 {hostid}") - else: - try: - hostname = r.json()["organism"] - except KeyError: - print(f"Warning: unable to retrieve host name for id {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}") - else: - try: - taxid = r.json()["id"] - except KeyError: - print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") - taxid = '' - return taxid - - def args(): parser = ArgumentParser('Returns cell informations') parser.add_argument( @@ -113,9 +68,9 @@ help='ID of biomass reaction' ) parser.add_argument( - '--hostid', + '--hostname', type=str, - help='Extended name of the host organism' + help='Name of the host organism' ) parser.add_argument( '--taxid', @@ -126,6 +81,55 @@ return params +def get_taxon_id(hostid: str, bigg: bool): + ''' + Returns the taxonomy ID of the host organism + + Parameters + ---------- + hostid: str + Extended name of the host organism or host ID if from BiGG + bigg: bool + True if the model is from BiGG + + Returns + ------- + taxid: str + Taxonomy ID of the host organism + ''' + if not bigg: + return get_taxonid(hostid) + + hostname = '' + # Extended Name + server = 'http://bigg.ucsd.edu/api/v2/models/' + ext = 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 {hostid}") + else: + try: + hostname = r.json()["organism"] + except KeyError: + print(f"Warning: unable to retrieve host name for id {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}") + else: + try: + taxid = r.json()["id"] + except KeyError: + print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") + taxid = '' + return taxid + + def entry_point(): params = args() @@ -161,12 +165,7 @@ else: print(f'Biomass reaction ID: {biomass_id}') - # Model from BiGG - if params.bigg: - taxid = get_taxon_id(params.hostid) - # Model from user - else: - taxid = params.hostid + taxid = get_taxon_id(params.hostname, params.bigg) if params.taxid: with open(params.taxid, 'w') as f: |
b |
diff -r 768ed7cc0978 -r 6a2871e89352 get_sbml_model.xml --- a/get_sbml_model.xml Fri Sep 29 09:03:09 2023 +0000 +++ b/get_sbml_model.xml Wed Feb 14 15:25:38 2024 +0000 |
[ |
@@ -1,31 +1,25 @@ -<tool id="get_sbml_model" name="Pick SBML Model" version="0.1.0" profile="21.09" license="MIT"> +<tool id="get_sbml_model" name="Pick SBML Model" version="0.2.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> + <requirement type="package" version="0.1.1">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 - 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 #if str($cond_src.from_src) == 'from_bigg' '$model' --bigg - --taxid '$taxid' #else '${cond_src.input_file}' #end if - --hostid '${cond_src.hostid}' + --hostname '${cond_src.hostid}' + --taxid '$taxid' --comp '$compartments' --biomass '$biomass' ]]></command> @@ -36,11 +30,8 @@ <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="ID of the organism is required"/> + <param name="hostid" type="text" label="Model's fullname" help="Model extended name"> + <validator type="empty_field" message="Organism extended name required"/> </param> <param name="input_file" type="data" format="sbml,xml" label="SBML model" help="An SBML file is expected"/> </when> |