cokelaer / bioservices

Access to Biological Web Services from Python.
http://bioservices.readthedocs.io
Other
278 stars 60 forks source link

request for convenience in KEGG.lookfor_organism #222

Closed necoli1822 closed 1 year ago

necoli1822 commented 2 years ago

For short, it would be convenient to parse the result string from KEGG.lookfor_organism as a list, for instance,

from bioservices.kegg import KEGG from re import search

k = KEGG()

def kegg_organism_search(key): organism_list = [ i.split("\t") for i in k.list("organism").split("\n") if search(key,i) ] return organism_list

example

kegg_organism_search("coli")

Thank you.

cokelaer commented 2 years ago

@necoli1822 thanks for submitting this feature. Not sure I understand your request though. You used the lookfor_organism and this function returns a list with the hits of e.g. ecoli,

res = k.lookfor_organism('chia coli')

returns:

print(res[0])
T00007 eco Escherichia coli K-12 MG1655 Prokaryotes;Bacteria;Gammaproteobacteria - Enterobacteria;Escherichia

indeed. What you want is the KEGG code of 3 characters, which is the second item in the string. Is this what you expect ?

cokelaer commented 1 year ago

closing (no activity)