Answers.Body: <p>How very interesting ...</p>
  <p>Yes its easy just download the flat file database here:</p>
  <blockquote>
  <p><a href="https://ftp.ebi.ac.uk/pub/databases/chebi/Flat_file_tab_delimited/names.tsv.gz" rel="nofollow noreferrer">https://ftp.ebi.ac.uk/pub/databases/chebi/Flat_file_tab_delimited/names.tsv.gz</a></p>
  </blockquote>
  <p><strong>WARNING</strong>: it's a 5.5M file ... don't click the link unless you really want to download a file this size.</p>
  <p>You can simply load it straight into a <code>pandas</code> dataframe from <code>read_csv()</code> and then interrogation it via <code>loc</code>. You could place the header <code>NAME</code> 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. <code>sqlite3</code></p>
  <p>Here I just loaded it onto Excel and found the entry you were looking for ...</p>
  <p><a href="https://i.sstatic.net/nmGKa.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nmGKa.png" alt="enter image description here" /></a>
  ....</p>
  <p><a href="https://i.sstatic.net/ogolh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ogolh.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-14T14:13:39.423Z
Answers.Text: Edited: sorry a `pandas` `iloc()` solution wasn't appropriate.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-13T00:50:58.920Z
Answers.LastActivityDate: 2023-01-14T12:56:40.460Z
Answers.LastEditDate: 2023-01-14T12:56:40.460Z
Answers.UserDisplayName: M__
Body: <p>I can download information from ChEBI if I know the corresponding ChEBI ID:</p>
  <pre><code>from libchebipy import ChebiEntity
  chebi_entity = ChebiEntity(&quot;15903&quot;)
  </code></pre>
  <p>And then look at all the synonyms that the compound has:</p>
  <pre><code>chebi_entity.get_names()
  &gt; [{'_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'}]
  </code></pre>
  <p>Is there a way to get the ChEBI ID with one of  the synonyms?</p>
  <pre><code>beta-D-glucose -&gt; 15903
  </code></pre>
  <p>Is there any other python tool or web-api that can achieve this?</p>
  
Tags: <embl>
Title: Search ChebiEntity search by common or synonym name?
ThreadText: # Search ChebiEntity search by common or synonym name?
  
  (Asked by: username_0 on 2023-01-12)
  
  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?
  
  **Tags:** embl
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-01-13. Score: 1
  
  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](https://i.sstatic.net/nmGKa.png)](https://i.sstatic.net/nmGKa.png)
  ....
  
  [![enter image description here](https://i.sstatic.net/ogolh.png)](https://i.sstatic.net/ogolh.png)
  
  > **Comments:**
  > **username_1**: Edited: sorry a `pandas` `iloc()` solution wasn't appropriate.  
  
  ---
  
  