Answers.Body: <p>Yes, RDKit can be used, however, if you installed it with <code>conda</code> it will not work out of the box for inChi key fetching. You can either spend some time installing the missing bit or use something else. It is not like Mol2 support in RDKit, which shouldn't be used, it is just not worth the bother.</p>
  
  <p>I would suggest <a href="https://pubchemdocs.ncbi.nlm.nih.gov/pug-rest" rel="nofollow noreferrer">PubChem's RESTFul API</a>.</p>
  
  <p>Say </p>
  
  <pre><code> import requests
   ethanol = 'LFQSCWFLJHTTHZ-UHFFFAOYSA-N'
   r = requests.get(f'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/{ethanol}/property/CanonicalSMILES/JSON').json()
   smiles = r['PropertyTable']['Properties'][0]['CanonicalSMILES']
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-19T23:56:51.790Z
Answers.Text: Hey, thanks for the answer. Though I get {'Fault': {'Code': 'PUGREST.BadRequest',
    'Message': 'Missing structure string',
    'Details': ["An argument for 'inchi' must be provided in the URL path or POST data"]}} when I run your code.
Answers.UserDisplayName: Soerendip
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-20T08:45:10.283Z
Answers.Text: Sorry for that. I fixed the typo by using your code. But I am glad it works now!
Answers.UserDisplayName: Matteo Ferla
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-17T09:11:44.730Z
Answers.LastActivityDate: 2019-11-20T08:42:32.597Z
Answers.LastEditDate: 2019-11-20T08:42:32.597Z
Answers.UserDisplayName: Matteo Ferla
Answers.Body: <p>Slightly modified Matteos answer:</p>
  
  <pre><code>import requests
  def get_smiles_from_inchikey(inchikey):
      r = requests.get(f'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/{inchikey}/property/CanonicalSMILES/JSON').json()
      return r['PropertyTable']['Properties'][0]['CanonicalSMILES']
  
  inchikey = 'SGNXVBOIDPPRJJ-UHFFFAOYSA-N'
  get_smiles_from_inchikey(inchikey)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-20T00:14:46.267Z
Answers.LastActivityDate: 2019-11-20T00:14:46.267Z
Answers.UserDisplayName: Soerendip
Body: <p>I am looking for a python package that can convert InChi keys (e.g.SGNXVBOIDPPRJJ-UHFFFAOYSA-N) to molecular structure or SMILES strings. Can I do that with RDKit? </p>
  
  <p>The key comes from: <a href="https://www.metabolomicsworkbench.org/databases/refmet/refmet_latest.txt" rel="nofollow noreferrer">https://www.metabolomicsworkbench.org/databases/refmet/refmet_latest.txt</a></p>
  
Tags: <structural-biology>
Title: Is there a Python package to convert InChi to molecular structures?
ThreadText: # Is there a Python package to convert InChi to molecular structures?
  
  (Asked by: username_0 on 2019-11-09)
  
  I am looking for a python package that can convert InChi keys (e.g.SGNXVBOIDPPRJJ-UHFFFAOYSA-N) to molecular structure or SMILES strings. Can I do that with RDKit?
  
  The key comes from: <https://www.metabolomicsworkbench.org/databases/refmet/refmet_latest.txt>
  
  **Tags:** structural-biology
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-11-17. Score: 3 | Accepted answer
  
  Yes, RDKit can be used, however, if you installed it with `conda` it will not work out of the box for inChi key fetching. You can either spend some time installing the missing bit or use something else. It is not like Mol2 support in RDKit, which shouldn't be used, it is just not worth the bother.
  
  I would suggest [PubChem's RESTFul API](https://pubchemdocs.ncbi.nlm.nih.gov/pug-rest).
  
  Say
  
  ```
   import requests
   ethanol = 'LFQSCWFLJHTTHZ-UHFFFAOYSA-N'
   r = requests.get(f'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/{ethanol}/property/CanonicalSMILES/JSON').json()
   smiles = r['PropertyTable']['Properties'][0]['CanonicalSMILES']
  
  ```
  
  > **Comments:**
  > **username_0**: Hey, thanks for the answer. Though I get {'Fault': {'Code': 'PUGREST.BadRequest',   'Message': 'Missing structure string',   'Details': ["An argument for 'inchi' must be provided in the URL path or POST data"]}} when I run your code.  
  > **username_1**: Sorry for that. I fixed the typo by using your code. But I am glad it works now!  
  
  ---
  
  ### Answer by username_0 on 2019-11-20. Score: 2
  
  Slightly modified Matteos answer:
  
  ```
  import requests
  def get_smiles_from_inchikey(inchikey):
      r = requests.get(f'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/{inchikey}/property/CanonicalSMILES/JSON').json()
      return r['PropertyTable']['Properties'][0]['CanonicalSMILES']
  
  inchikey = 'SGNXVBOIDPPRJJ-UHFFFAOYSA-N'
  get_smiles_from_inchikey(inchikey)
  
  ```
  
  
  ---
  
  