Programmatic Access to Web-Based Chemical Information – Examples

The above links brings you to a page where you can access and discuss examples created by faculty.

Sources

File types available from sources are given in parentheses.

[CDK] https://ws1.bmc.uu.se/cdk (XML)
[CDKD] CDK-Depict (SVG)
[CIR] NCI/CADD Chemical Identifier Resolver (TXT, SDF, GIF)
[CIP] TOXNET ChemicalIDplus (HTML only; no API)*
[CS] ChemSpider (XML, PNG)*
[NWB] NIST Web Book (HTML only; no API)*
[PCE] PubChem E-Util (JSON, XML)
[PCR] PubChem PUG REST (TXT, CSV, XML, JSON, JSONP, SDF, PNG)
[WK] Wikipedia (JSON, JSONP, XML)

* no direct JavaScript access (site does not allow direct access via AJAX; JavaScript and JSmol both use a proxy server)

 

Examples

1. Tasks that are solved with a single API call which returns the response in plain text or as a single object without any need of parsing or further processing

    1.1 Obtaining an InChI from a name or other chemical identifier
        1.1.1 [CIR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/CADD_InChI_JS.htm
        1.1.2 [CIR] JSmol: https://chemapps.stolaf.edu/olcc/examples/jmol/CADD_InChI_Jmol.htm
        1.1.3 [PCR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/PubChem_InChI_JS.htm
        1.1.4 [PCR] JSmol: https://chemapps.stolaf.edu/olcc/examples/jmol/PubChem_InChI_Jmol.htm
        1.1.5 [CIR] MS Excel (from 2013): https://drive.google.com/file/d/0B5ln9gFZnHD4YUVmOTZmWWJiS2c
        1.1.6 [CIR] LO Calc: https://drive.google.com/file/d/0B5ln9gFZnHD4ZFgyanNrVlN3ME0
        1.1.7 [CIR] Google Sheets: https://docs.google.com/spreadsheets/d/1q4MyOfu8x7ocNke6vq0uOP_P8CNAK-fIIK0cyyggJPo/copy
        1.1.8 [CIR] Google Scripts: https://docs.google.com/spreadsheets/d/10odN2Fr406sZdNpoFEUFexPeTBe7ENoUColxYcHEOj0/copy
        1.1.9 [PCR] Google Scripts: https://docs.google.com/spreadsheets/d/18r_EJxmKsKaPCOoHwzyiWJDoWU31lXOEMtswPc_3Vrk/copy
        1.1.10 [CIR] Python: http://www.codeskulptor.org/#user41_g77tnnbEBT_2.py

    1.2 Obtaining a list of known chemical names from a name or other chemical identifier
        1.2.1 [CIR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/CADD_Names_JS.htm
        1.2.2 [CIR] JSmol: https://chemapps.stolaf.edu/olcc/examples/jmol/CADD_Names_Jmol.htm
        1.2.3 [PCR] JavaScript: https://drive.google.com/file/d/0B5ln9gFZnHD4TVV5NXlxcVI2dU0

    1.3 Obtaining an SDF file from a name or other chemical identifier
        1.3.1 [CIR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/CADD_SDF_JS.htm
        1.3.2 [CIR] JSmol: https://chemapps.stolaf.edu/olcc/examples/jmol/CADD_SDF_Jmol.htm
        1.3.3 [PCR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/PubChem_SDF_JS.htm
        1.3.4 [PCR] JSmol: https://chemapps.stolaf.edu/olcc/examples/jmol/PubChem_SDF_Jmol.htm

    1.4 Obtaining a chemical structure drawing as an image from a name or other chemical identifier
        1.4.1 [CIR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/CADD_image_JS.htm
        1.4.2 [CIR] JSmol: https://chemapps.stolaf.edu/olcc/examples/jmol/CADD_image_Jmol.htm
        1.4.3 [PCR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/PubChem_image_JS.htm
        1.4.4 [PCR] JSmol: https://chemapps.stolaf.edu/olcc/examples/jmol/PubChem_image_Jmol.htm

    1.5 Obtaining a chemical structure drawing as a vector image from a SMILES:
        1.5.1 [CDKD] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/CDK_image_JS.htm (SVG from SMILES)

2. Tasks that are solved with a single API call that returns the response as a structured text file (tablular data, CSV, HTML) or data structure (XML, JSON)

    2.1 Find a CAS Registry Number from a name or other chemical identifier
        2.1.1 [NWB] MS Excel: https://drive.google.com/file/d/0B5ln9gFZnHD4MUdkWWd5SlpTRUk
        2.1.2 [NWB] LO Calc: https://drive.google.com/file/d/0B5ln9gFZnHD4eVd0R2xHeFYwWlk
        2.1.3 [NWB] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/NIST_CASRN_JS.htm

    2.2 Find the boiling point from a CAS Registry Number
        2.2.1 [CIP] Google Sheets: https://docs.google.com/spreadsheets/d/1qrxQiiDG_rlUhPccEkzUowKYEml21EMlmXWEGLOqc0Q/copy (as XML)
        2.2.2 [CIP] VBA: https://drive.google.com/file/d/0B5ln9gFZnHD4aFR5aGVOUTB0aHc (as string data)
        2.2.3 [CIP] Javascript: https://chemapps.stolaf.edu/olcc/examples/js/CIP_BP_JS.htm (as XML)

3. Tasks that are solved using more than one API call in sequence

    3.1 Information for compounds with specific properties or ranges of properties
         3.1.1 [PCE] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/PubChem_EUtil_JS.htm
         3.1.2 [PCE/PCR] Google Script: https://docs.google.com/spreadsheets/d/1KUV3kbNWZ-ED57-E-J-J1MMOim1ljmz_MyaFuae6QUg/copy

    3.2 Obtaining a ChemSpider ID from a name or other chemical identifier
         3.2.1 [CIR/CS] MS Excel (from 2013): https://drive.google.com/file/d/0B5ln9gFZnHD4UUJscFNGQ0pqQU0
         3.2.2 [CIR/CS] JSmol: https://chemapps.stolaf.edu/olcc/examples/js/CS_image2_JS.htm

    3.3 Download an IR spectrum from a compound name (using NIST)
         3.3.1 [NWB] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/NIST_IR_JS.htm

    3.4 Download a IR/Mass/UVVis spectrum from a SMILES (using NIST)
         3.4.1 [PCR/CIP/NWB] Google Sheets: https://docs.google.com/spreadsheets/d/1iKEXWUk4JQQdueklu8-PFbg-b0GNHYC9hIvoywEOY4I/copy
             (note the document includes a minimal script with a user-defined function to do URI-encoding)

    3.5 Do two SMILES correspond to the same molecule?
         3.5.1 [CIR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/SMILES_Match_JS.htm

4. Tasks that involve using a single API that returns multiple responses, which need to be processed using an array, list, or object

   4.1 Information for compounds with specific properties or ranges of properties
         4.1.1 [PCE] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/PubChem_EUtil_JS.htm

   4.2 Search for the translation of a compound name to a different languages
         4.2.1 [WK] JavaScript: https://drive.google.com/file/d/0B5ln9gFZnHD4UUlOMjZzTHptZ28

5. Tasks that involve an asynchronous queued request that requires polling of the server to determine completion

   5.1 Find the isomers of a compound from a name or molecular formula

         5.1.1 [PCR] VBA: https://drive.google.com/file/d/0B5ln9gFZnHD4VjZTVkw5RlZkc0k
         5.1.2 [PCR] JavaScript: https://chemapps.stolaf.edu/olcc/examples/js/PubChem_Polling_JS.htm

             (but see nonpolling example that accomplishes the same: https://chemapps.stolaf.edu/olcc/examples/js/PubChem_Fast_JS.htm)

 

Useful Web Tools

Structure drawings from SMILES, with SMARTS-based highlighting https://chemapps.stolaf.edu/olcc/examples/cdk/depict/cdk_depict.htm

Interconverting 2D and 3D using SMILES https://chemapps.stolaf.edu/jmol/jsmol/jsmetest2.htm

    

 

Rating: 
0
No votes yet
Join the conversation.

Comments 1

OLCC s12's picture
OLCC s12 | Mon, 04/10/2017 - 22:20
 // This next step, retrieving the ChemSpider id, requires a server-side proxy
// because ChemSpider does not allow direct AJAX access.
// This is our server-side proxy for accessing ChemSpider.
Jmol._serverUrl = "https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php";

I took the above code from this page here, which was mentioned in example 3.2.2 above about using JSmol to get the ChemSpider ID from an InChI. This question may best be suited for my class project page, but would the server-side proxy be needed to access any external service from JSMol or is this specific just to the sources above with the asterick that mention needing the proxy. If so would this just be due to a security issue on the database side of not allowing javascript direct access or is it just a conflict with the way javascripts language talks to the code running the API?

Andrew

 

Annotations