# HG changeset patch # User tduigou # Date 1707924338 0 # Node ID 6a2871e893527e9d4b3b656f57f8098f610074cc # Parent 768ed7cc097899366a84a57ce1f5a4fc64c56318 planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 537d7fefe58984b8f7ca66010153a2fdc35ddf4b 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: 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 @@ - + Get an SBML model (BiGG) curl gzip python-libsbml requests - taxonid + taxonid '$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' ]]> @@ -36,11 +30,8 @@ - - - - - + +