Mercurial > repos > tduigou > get_sbml_model
diff get_infos.py @ 4:1482291aaa5c draft
planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 4a0b08beb8cdf51ab295a1f5f8c586d6bbaf5586
author | tduigou |
---|---|
date | Mon, 22 May 2023 14:57:40 +0000 |
parents | fa893f77dc22 |
children | 8dc4d3964ab5 |
line wrap: on
line diff
--- a/get_infos.py Sat Apr 29 16:44:33 2023 +0000 +++ b/get_infos.py Mon May 22 14:57:40 2023 +0000 @@ -62,22 +62,26 @@ try: hostname = r.json()["organism"] except KeyError: - print(f"*** Error: unable to retrieve host name for id {params.hostid}") - return -1 - # 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}") + print(f"Warning: unable to retrieve host name for id {params.hostid}") + hostname = '' + if not hostname: + taxid = '' else: - try: - taxid = r.json()["parent"]["id"] - except KeyError: + # 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}") - with open(params.taxid, 'w') as f: - f.write('#ID\n') - f.write(f'{taxid}\n') + else: + try: + taxid = r.json()["id"] + except KeyError: + print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") + taxid = '' + with open(params.taxid, 'w') as f: + f.write('#ID\n') + f.write(f'{taxid}\n') if __name__ == "__main__":