Closed necoli1822 closed 1 year 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 ?
closing (no activity)
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.