2
$\begingroup$

I can download information from ChEBI if I know the corresponding ChEBI ID:

from libchebipy import ChebiEntity
chebi_entity = ChebiEntity("15903")

And then look at all the synonyms that the compound has:

chebi_entity.get_names()
> [{'_Name__name': 'beta-D-Glucose', '_Name__typ': 'SYNONYM', '_Name__source': 'KEGG COMPOUND', '_Name__adapted': False, '_Name__language': 'en'},
 {'_Name__name': 'beta-D-glucose', '_Name__typ': 'NAME', '_Name__source': 'UniProt', '_Name__adapted': False, '_Name__language': 'en'},
 {'_Name__name': 'beta-D-glucopyranose', '_Name__typ': 'IUPAC NAME', '_Name__source': 'IUPAC', '_Name__adapted': False, '_Name__language': 'en'},
 {'_Name__name': 'BETA-D-GLUCOSE', '_Name__typ': 'SYNONYM', '_Name__source': 'PDBeChem', '_Name__adapted': False, '_Name__language': 'en'},
 {'_Name__name': 'WURCS=2.0/1,1,0/[a2122h-1b_1-5]/1/', '_Name__typ': 'SYNONYM', '_Name__source': 'GlyTouCan', '_Name__adapted': False, '_Name__language': 'en'}]

Is there a way to get the ChEBI ID with one of the synonyms?

beta-D-glucose -> 15903

Is there any other python tool or web-api that can achieve this?

$\endgroup$

1 Answer 1

1
$\begingroup$

How very interesting ...

Yes its easy just download the flat file database here:

https://ftp.ebi.ac.uk/pub/databases/chebi/Flat_file_tab_delimited/names.tsv.gz

WARNING: it's a 5.5M file ... don't click the link unless you really want to download a file this size.

You can simply load it straight into a pandas dataframe from read_csv() and then interrogation it via loc. You could place the header NAME as the index. There are other way in, you can shift the dataframe to a dictionary and interrogate that way, or place it straight it SQL via e.g. sqlite3

Here I just loaded it onto Excel and found the entry you were looking for ...

enter image description here ....

enter image description here

$\endgroup$
1
  • $\begingroup$ Edited: sorry a pandas iloc() solution wasn't appropriate. $\endgroup$
    – M__
    Commented Jan 14, 2023 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.