comparison 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
comparison
equal deleted inserted replaced
3:f59e65c1606a 4:1482291aaa5c
60 print(f"Warning: unable to retrieve host name for id {params.hostid}") 60 print(f"Warning: unable to retrieve host name for id {params.hostid}")
61 else: 61 else:
62 try: 62 try:
63 hostname = r.json()["organism"] 63 hostname = r.json()["organism"]
64 except KeyError: 64 except KeyError:
65 print(f"*** Error: unable to retrieve host name for id {params.hostid}") 65 print(f"Warning: unable to retrieve host name for id {params.hostid}")
66 return -1 66 hostname = ''
67 # TAXON ID 67 if not hostname:
68 server = 'https://rest.ensembl.org' 68 taxid = ''
69 ext = f'/taxonomy/id/{hostname}?'
70 r = r_get(server+ext, headers={ "Content-Type" : "application/json"})
71 if not r.ok:
72 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}")
73 else: 69 else:
74 try: 70 # TAXON ID
75 taxid = r.json()["parent"]["id"] 71 server = 'https://rest.ensembl.org'
76 except KeyError: 72 ext = f'/taxonomy/id/{hostname}?'
73 r = r_get(server+ext, headers={ "Content-Type" : "application/json"})
74 if not r.ok:
77 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}") 75 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}")
78 with open(params.taxid, 'w') as f: 76 else:
79 f.write('#ID\n') 77 try:
80 f.write(f'{taxid}\n') 78 taxid = r.json()["id"]
79 except KeyError:
80 print(f"Warning: unable to retrieve taxonomy ID for host organism {hostname}")
81 taxid = ''
82 with open(params.taxid, 'w') as f:
83 f.write('#ID\n')
84 f.write(f'{taxid}\n')
81 85
82 86
83 if __name__ == "__main__": 87 if __name__ == "__main__":
84 entry_point() 88 entry_point()