### Compound Auto-Complete Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/autocomplete An example of how to use the auto-complete API to get suggestions for the term 'aspirin' in the 'compound' dictionary, requesting up to 6 results in JSONP format. ```APIDOC ## Example Queries https://pubchem.ncbi.nlm.nih.gov/rest/autocomplete/compound/aspirin/jsonp?limit=6 ``` callback({ "status": { "code": 0 }, "total": 6, "dictionary_terms": { "compound": [ "aspirin", "Aspirine", "Aspirin sodium", "Aspirin anhydride", "Aspirin methyl ester", "Aspirin calcium" ] } }) ``` ``` -------------------------------- ### Install Required Python Packages Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Install the necessary Python libraries for interacting with Google Cloud services. Ensure these are installed in your Python environment. ```bash pip install google-cloud-compute google-auth google-api-python-client google-cloud-resource-manager ``` -------------------------------- ### Assay Auto-Complete Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/autocomplete An example of how to use the auto-complete API to get suggestions for the term 'p68' in the 'assay' dictionary, requesting up to 8 results in JSON format. ```APIDOC https://pubchem.ncbi.nlm.nih.gov/rest/autocomplete/assay/p68/json?limit=8 ``` { "status": { "code": 0 }, "total": 8, "dictionary_terms": { "assay": [ "p68 - Protein Target", "p68-PAK - Protein Target", "p68 kinase - Protein Target", "Inhibition of HIV2 reverse transcriptase p68/p54 expressed in Escherichia coli - Assay Name", "Inhibition of HIV2 reverse transcriptase p68/p54 expressed in Escherichia coli at 495 uM - Assay Name", "RPL21P68 - Gene Target", "gp68 - Protein Target", "CEP68 - Gene Target" ] } } ``` ``` -------------------------------- ### Asynchronous Search Example (Deprecated) Source: https://pubchem.ncbi.nlm.nih.gov/docs/pug-rest Example of an asynchronous search request using a listkey, which is a deprecated method. ```URL https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/listkey/xxxxx/cids/XML ``` -------------------------------- ### Resolve Synonym URI Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-synonym Example of how to resolve a URI for a synonym using its MD5 hash. ```http http://rdf.ncbi.nlm.nih.gov/pubchem/synonym/MD5_8ab309455b7969e69fa0b7602239b203 ``` -------------------------------- ### Taxonomy Auto-Complete Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/autocomplete An example of how to use the auto-complete API to get suggestions for the term 'mouse' in the 'taxonomy' dictionary, requesting up to 5 results in JSON format. ```APIDOC https://pubchem.ncbi.nlm.nih.gov/rest/autocomplete/taxonomy/mouse/json?limit=5 ``` { "status": { "code": 0 }, "total": 5, "dictionary_terms": { "taxonomy": [ "mouse", "mousepox", "mousepox virus", "mouse-ear cress", "Mouse adenovirus" ] } } ``` ``` -------------------------------- ### Install Python 3 on Ubuntu Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Install the Python 3 interpreter on Ubuntu systems. This is a prerequisite for running the PubChem RDF cloud scripts. ```bash sudo apt install python3 ``` -------------------------------- ### Example PubChemRDF URI Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf Example URI for accessing RDF data for a specific compound. ```text http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID60823 ``` -------------------------------- ### Substring Search Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/pubchemrdf-1-5beta This example demonstrates how to perform a substring search on chemical substance synonyms using the PubChemRDF REST interface. ```APIDOC ## Substring Search ### Description Performs a substring search on chemical substance synonyms. ### Method GET ### Endpoint https://pubchem.ncbi.nlm.nih.gov/rest/rdf/query ### Query Parameters - **graph** (string) - Required - Specifies the graph to query, e.g., 'synonym'. - **name** (string) - Required - The substring to search for. - **contain** (boolean) - Required - Set to 'true' to enable substring matching. ### Request Example ``` https://pubchem.ncbi.nlm.nih.gov/rest/rdf/query?graph=synonym&name=aspirin&contain=true ``` ``` -------------------------------- ### Resolve InChIKey URI Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-inchikey Example of how to construct a URI to resolve an InChIKey. The InChIKey value is case-sensitive. ```text http://rdf.ncbi.nlm.nih.gov/pubchem/inchikey/BSYNRYMUTXBXSQ-UHFFFAOYSA-N ``` -------------------------------- ### InChI Structure Search Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/quick-search Provides an example of an InChI string for Aspirin, used for direct structure-based queries in PubChem Quick Search. ```inchi InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12) ``` -------------------------------- ### SPARQL-like Query Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/pubchemrdf-1-5beta This example shows how to use the PubChemRDF REST interface for simple SPARQL-like queries, such as retrieving ChEBI class assignments for PubChem substances. ```APIDOC ## SPARQL-like Query ### Description Provides simple SPARQL-like query capabilities for grouping and filtering resources. ### Method GET ### Endpoint https://pubchem.ncbi.nlm.nih.gov/rest/rdf/query ### Query Parameters - **graph** (string) - Required - Specifies the graph to query, e.g., 'substance'. - **predicate** (string) - Required - The predicate to filter by, e.g., 'rdf:type'. ### Request Example ``` https://pubchem.ncbi.nlm.nih.gov/rest/rdf/query?graph=substance&predicate=rdf:type ``` ``` -------------------------------- ### Example cURL Accept Header for HTML Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-rest This is an example of the 'Accept' header that a web browser like Google Chrome might send when requesting RDF triples. It indicates a preference for HTML format. ```http Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 ``` -------------------------------- ### Download Local QLever Docker Files Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Download the Docker files for setting up a local QLever instance. Extract the archive and navigate to the docker-files directory. ```bash curl -s ftp://ftp.ncbi.nlm.nih.gov/pubchem/cloud/local_qlever_docker.tar -o local_qlever_docker.tar tar -xvf local_qlever_docker.tar cd docker-files ``` -------------------------------- ### Create Cloud VM with QLever Index Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Create a cloud virtual machine instance with a QLever index. This is for setting up the QLever search engine. ```python python3 create_cloud_vm.py qlever ``` -------------------------------- ### Gene Auto-Complete Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/autocomplete An example of how to use the auto-complete API to get suggestions for the term 'egfr' in the 'gene' dictionary, requesting up to 5 results in JSONP format. ```APIDOC https://pubchem.ncbi.nlm.nih.gov/rest/autocomplete/gene/egfr/jsonp?limit=5 ``` callback({ "status": { "code": 0 }, "total": 5, "dictionary_terms": { "gene": [ "EGFR", "NGFR", "OGFR", "DHFR", "EGR1" ] } }) ``` ``` -------------------------------- ### Build and Run Local QLever Docker Container on Windows/Mac Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Build the Docker image for the QLever container and start it on Windows or Mac. This command maps port 7023 for QLever access. ```bash docker build -t cloud-graph-db . docker run --rm -d --name graph-db-container -p 7023:7023 cloud-graph-db ``` -------------------------------- ### Test QLever Instance Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Send a query to the QLever instance to test its responsiveness. Replace 'vm_ip_address' with the actual IP of your QLever instance. ```bash curl -s vm_ip_address:7023 -H "Accept: text/tab-separated-values" --data-urlencode query="SELECT * WHERE { ?s ?p ?o } LIMIT 3" ``` -------------------------------- ### PUG and eUtils for Data Analysis Source: https://pubchem.ncbi.nlm.nih.gov/docs/power-user-gateway This example demonstrates the integration of PUG with NCBI eUtils and Entrez History to enable powerful programmatic data analysis for PubChem and other Entrez databases. No specific setup or imports are shown, as this is a conceptual overview. ```text PUG and eUtils together make possible a wide variety of powerful programmatic data analysis tools for PubChem and other Entrez databases. ``` -------------------------------- ### Download Local Virtuoso Docker Files Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Download the Docker files for setting up a local Virtuoso instance. Extract the archive and navigate to the docker-files directory. ```bash curl -s ftp://ftp.ncbi.nlm.nih.gov/pubchem/cloud/local_virtuoso_docker.tar -o local_virtuoso_docker.tar tar -xvf local_virtuoso_docker.tar cd docker-files ``` -------------------------------- ### Build and Run Local QLever Docker Container on Linux Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Build the Docker image for the QLever container and start it on a Linux system. This command maps port 7023 for QLever access. ```bash sudo docker build -t cloud-graph-db . sudo docker run --rm -d --name graph-db-container -p 7023:7023 cloud-graph-db ``` -------------------------------- ### Create Cloud VM by Loading TTL Files Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Create a cloud virtual machine instance by loading Turtle (TTL) files. Modify the domain_list in the configuration file to specify which subdomains to load. ```python python3 create_cloud_vm.py virtuoso_ttl ``` -------------------------------- ### Initialize GCP Project Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Initialize your GCP project using the provided Python script. This sets up the necessary configurations for cloud resource deployment. ```python python3 create_cloud_vm.py initialize_project ``` -------------------------------- ### Create Cloud VM with Existing Virtuoso Database Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Create a cloud virtual machine instance pre-loaded with an existing Virtuoso database. This is useful for quickly starting with a full dataset. ```python python3 create_cloud_vm.py virtuoso_db ``` -------------------------------- ### Download Source: https://pubchem.ncbi.nlm.nih.gov/docs/pug-soap Given a list key, prepares a file containing specified records in the selected format for download. Returns a download key. This is an asynchronous operation. ```APIDOC ## Download ### Description Given a list key, prepare for download a file containing those records in the selected format. Returns a download key. ### Synchronicity Asynchronous ``` -------------------------------- ### CID Structure Search Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/quick-search Demonstrates how to initiate a structure search using a Compound ID (CID) directive. ```text CID:123 structure ``` -------------------------------- ### AssayDownload Source: https://pubchem.ncbi.nlm.nih.gov/docs/pug-soap Given an assay key, prepares a file containing assay data in the selected format for download. Compression is optional and defaults to gzip. Returns a download key. This is an asynchronous operation. ```APIDOC ## AssayDownload ### Description Given an assay key, prepare for download a file containing an assay data table in the selected format. Compression is optional and defaults to gzip (.gz). Returns a download key. ### Synchronicity Asynchronous ``` -------------------------------- ### Install Python 3 on CentOS Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-cloud-install Install the Python 3 interpreter on CentOS systems. This is a prerequisite for running the PubChem RDF cloud scripts. ```bash sudo yum install -y python3 ``` -------------------------------- ### SMILES Structure Search Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/quick-search Provides an example of a SMILES string for Aspirin, used for direct structure-based queries in PubChem Quick Search. ```smiles CC(=O)OC1=CC=CC=C1C(=O)O ``` -------------------------------- ### SMARTS Structure Search Example Source: https://pubchem.ncbi.nlm.nih.gov/docs/quick-search Provides an example of a SMARTS pattern for the amino acid backbone, used for substructure searches in PubChem Quick Search. ```smarts SMARTS amino acid pattern ``` -------------------------------- ### URI Dereferencing Examples Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-rest Examples of how to dereference URIs to retrieve RDF triples in different formats using URI suffix extensions or HTTP Accept headers. ```APIDOC ## URI Dereferencing URIs can be resolved through the RESTful interface by either URI Suffix Extension or HTTP Accept Header. By default, it uses URI Suffix Extension first, then HTTP Accept Header. If neither of them is provided, it will return RDF triples in HTML format. The supported formats are listed in Table 3. **Table 3**. The MIME types supported in the PubChem RDF REST interface for dereferencing URIs. MIME Type| HTTP Accept Header| URI Suffix Extension ---|---|--- Abbreviated RDF/XML| **application/rdf+xml+abbrev**| **rdfxml-abbrev** RDF/XML| **application/rdf+xml** **text/rdf**| **rdfxml** **rdf** **xml** HTML| **application/xhtml+xml** **text/html**| **html** **htm** TURTLE¹| **application/n3** **application/rdf+n3** **application/turtle** **application/x-turtle** **text/n3** **text/turtle** **text/rdf+n3** **text/rdf+turtle**| **turtle** **ttl** **n3** JSON²| **application/json** **text/json**| **json** JSON-LD³| **application/x-json+ld** **application/x-json+rdf** **application/json+ld** **application/json+rdf** **application/ld+json** **application/rdf+json**| **Jsonld** **Json-ld** **ldjson** **ld-json** N-TRIPLES| **text/plain**| **ntriples** **nt** For instance, the following URLs can present the RDF triples with respect to CID2244 (Aspirin) in various RDF data formats: * http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID2244.rdf * http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID2244.html * http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID2244.turtle * http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID2244.json * http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID2244.jsonld * http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID2244.ntriples Different types of presentations can be produced through specifying the HTTP accept header as well. For instance, if the Linux cURL command is used to retrieve RDF triples regarding to CID2244, the following commands will output the RDF triples into the files: ```bash curl -L -H "Accept: text/rdf" -o CID2244.rdf http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID2244 ``` If no HTTP header is specified, the default output format is html (text/html). If web browsers are used to retrieve RDF triples, HTML format is typically the default. For instance, what Google Chrome sends in the accept header would be something like: ``` Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 ``` which means that it will take HTML or XML or others, but it prefers HTML (q=1.0) to XML (q=0.9) and others (q=0.8). ### Redirection The resolution of URIs under `http://rdf.ncbi.nlm.nih.gov/pubchem/` domain will return a 303 redirect HTTP status code, and the request will be redirected to `https://pubchem.ncbi.nlm.nih.gov/rest/rdf/` domain. ### Pagination The URI dereferencing service supports pagination using offset and limit parameters. For instance, the following URL retrieves the second page of triples for a compound, with an offset of 100 and a limit of 100: https://pubchem.ncbi.nlm.nih.gov/rdf/compound/CID2244.nt?limt=100&offset=100 Additionally, the default HTML output format includes navigation links such as `Previous Page` and `Next Page` at the bottom of the page. http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID2244 ``` -------------------------------- ### Download Source: https://pubchem.ncbi.nlm.nih.gov/docs/pug-soap-reference Given a list key, prepare for download a file containing those records in the selected format. Returns a download key. Asynchronous. If SynchronousSingleRecord is set to true and the ListKey contains only a single ID, a Base64 string of data is returned synchronously. ```APIDOC ## Download ### Description Given a list key, prepare for download a file containing those records in the selected format. See the web download service documentation for more detail on the supported formats and file types. Returns a download key. Asynchronous. Note that if SynchronousSingleRecord is set to true, and the ListKey contains only a single ID, then a Base64 string of data is returned synchronously in the response, instead of going through the download file. ### Method POST ### Endpoint /download ### Parameters #### Query Parameters - **list_key** (string) - Required - The key for the list of records. - **format** (string) - Optional - The desired format for the download. - **SynchronousSingleRecord** (boolean) - Optional - If true and list contains a single ID, returns data synchronously. ### Response #### Success Response (200) - **download_key** (string) - A key to retrieve the download URL, or Base64 encoded data if SynchronousSingleRecord is true and applicable. ``` -------------------------------- ### InChIKey RDF Triple Examples Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-inchikey Examples of RDF triples representing InChIKey properties. These demonstrate how InChIKey data is structured and linked within the PubChem RDF dataset. ```turtle inchikey:VYZAHLCBVHPDDF-UHFFFAOYSA-N rdf:type vocab:InChIKey . ``` ```turtle inchikey:VYZAHLCBVHPDDF-UHFFFAOYSA-N rdf:type cheminf:CHEMINF_000399 . ``` ```turtle inchikey:VYZAHLCBVHPDDF-UHFFFAOYSA-N sio:SIO_000300 "VYZAHLCBVHPDDF-UHFFFAOYSA-N" . ``` ```turtle inchikey:VYZAHLCBVHPDDF-UHFFFAOYSA-N dcterms:subject mesh:M0006475 . ``` ```turtle inchikey:VYZAHLCBVHPDDF-UHFFFAOYSA-N sio:SIO_000011 compound:CID6 . ``` -------------------------------- ### Execute Bulk RDF Load Source: https://pubchem.ncbi.nlm.nih.gov/docs/rdf-load Initiate the bulk loading process using `rdf_loader_run()` in multiple isql sessions. Use `wait` to ensure all processes complete before proceeding. A final `checkpoint;` is recommended. ```shell isql 1111 dba dba exec="rdf_loader_run();" & ``` ```shell isql 1111 dba dba exec="rdf_loader_run();" & ``` ```shell isql 1111 dba dba exec="rdf_loader_run();" & ``` ```shell isql 1111 dba dba exec="rdf_loader_run();" & ``` ```shell isql 1111 dba dba exec="rdf_loader_run();" & ``` ```shell isql 1111 dba dba exec="rdf_loader_run();" & ``` ```shell isql 1111 dba dba exec="rdf_loader_run();" & ``` ```shell wait ``` ```shell isql 111 dba dba exec="checkpoint;" ``` -------------------------------- ### Download SDF file using Entrez query key and webenv Source: https://pubchem.ncbi.nlm.nih.gov/docs/power-user-gateway Use this XML structure to download a gzipped SDF file of query hits by providing the Entrez query key and webenv obtained from a previous query. Specify the database, desired format, and compression. ```xml                                                                                           pccompound                   26                   0BPLhFE_YfmLOCUMsO7FDRuhXLxgPqzfs-aB_O2nILEnCpSEb-AIRQzeQ0LTaQNNlpK8XkxiDcX71it@46C3203C79E0BE30_0000SID                                                                                                               ``` -------------------------------- ### AssayDownload Source: https://pubchem.ncbi.nlm.nih.gov/docs/pug-soap-reference Prepares an assay data table for download in a selected format. Returns a download key. This operation is asynchronous. ```APIDOC ## AssayDownload ### Description Given an assay key, prepare for download a file containing an assay data table in the selected format. See the assay query section of the PUG service documentation for more detail on the supported formats. Compression is optional and defaults to gzip (.gz). Returns a download key. Asynchronous. ### Action `http://pubchem.ncbi.nlm.nih.gov/AssayDownload` ### Input (Literal) The input of this method is the argument AssayDownload having the structure defined by the following table. Element| Type| Occurs ---|---|--- | | 1..1 tns:AssayKey| s:string| 1..1 tns:AssayFormat| tns:AssayFormatType| 1..1 tns:eCompress| tns:CompressType| 0..1 ### Output (Literal) The output of this method is the argument AssayDownloadResponse having the structure defined by the following table. Element| Type| Occurs ---|---|--- | | 1..1 tns:DownloadKey| s:string| 1..1 ```