Skip to content Documentation

CTS-Lite

UC Davis Fiehn Lab

Feedback   

Documentation

CTS-Lite is a lightweight Chemical Translation Service, and the successor to the Fiehn Lab's original CTS. It allows users to easily match InChIs, InChIKeys, SMILES, Molecular Formulas, and PubChem CIDs against the 100+ million compounds from the PubChem database.

Contents

  1. Using CTS-Lite
  2. Query Types
    • Malformed Queries
  3. Match Levels
    • First Block Matches
    • PubChem Live Matches
  4. RDKit Conversion
  5. Top Hit Only
  6. Anno. Type Count
  7. ClassyFire
  8. REST API
    • Request Formats
    • Request Parameters
    • Response Formats

Using CTS-Lite

To use CTS-Lite, simply enter your queries into the input box on the main page. You can separate entries using spaces, tabs, or newlines. When you click Match, the results will be displayed in the results section. Results can be downloaded in JSON and CSV formats using the buttons provided.

Note: Queries are limited to 100,000 entries per request. With ClassyFire enabled, the limit is reduced to 1,000 entries (see Chemical Classification). Very large queries may take some time to process. Please be patient while the server handles your request.

Query Types

Query types are parsed using the following logic:

  • InChIKeys must be in the format XXXXXXXXXXXXXX-XXXXXXXXXX-X (14-10-1, all uppercase letters)
  • InChIs must start with InChI= (case-sensitive)
  • SMILES are first identified by the presence of structural characters: = # - / \ : . @ + [ ] ( )
  • PubChem CIDs are identified by numbers between 1 and 500 million
  • Molecular Formulas are recognized by starting with letters that cannot be at the start of SMILES: ADEGHKLMRTUVWXYZ
  • Converted SMILES / Converted InChI are SMILES or InChI queries that failed to match, but were then matched using their converted InChIKey. The SMILES/InChIs are converted to InChIKey using RDKit.
  • SMILES/Mol. Formula some queries, like C, are ambiguous and can be either SMILES or Molecular Formulas. In these cases, the query first tries to match against SMILES, and then Molecular Formula.

Malformed Queries

Malformed queries are identified as follows:

  • InChIKeys that match the regex pattern: ^[a-zA-Z]{12,16}-[a-zA-Z]{9,11}-[a-zA-Z]{0,2}$
  • InChIs that start with InChI=, but with improper capitalization, i.e. inchi=
  • PubChem CIDs that cannot be valid. This includes negative numbers, zero itself, numbers with leading zeros, and numbers above 500 million
  • Unidentified are queries that didn't fit any of the above criteria

Match Levels

First Block Matches

Given the setting for first block matches is enabled (the default), "InChIKey" queries can match by first block if they don't find an exact match in the local database. This gives the First Block match level. "Converted SMILES" queries can also match by first block, since they are SMILES queries that were converted to InChIKey and then reattempted. The first fourteen characters of the InChIKey are the key's first block.

For example, the query XLYOFNOQVPJJNP-XXXXXXXXXX-X would be a first block match with Water, whose key is XLYOFNOQVPJJNP-UHFFFAOYSA-N.

Since a first block match is not considered a miss, that query is not sent to PubChem Live, even if PubChem would have had an exact match. If you want exact matches only, disable first block matching using the settings cog in the web UI or by adding first_block_matches=false to the API request.

PubChem Live Matches

Queries that do not find a match in the local database are forwarded to PubChem. A live lookup is performed against all 124 million compounds of PubChem. PubChem Live queries take longer than local database matches.

A PubChem Live match can sometimes return something slightly different to the exact query provided by the user. For example, querying H4C will return CH4, and CH3COOH will return C2H4O2. This can even occur with some SMILES queries, because RDKit is used in the background to convert SMILES queries into InChIKeys before querying PubChem.

RDKit Conversion

The same compound can be written as many different SMILES strings, so a SMILES query with no exact match is converted to an InChIKey using RDKit and searched again. If the local database still has no match, that InChIKey is used for the live PubChem lookup. InChI queries not found locally are converted to an InChIKey the same way before searching PubChem.

A match found this way is returned with the query type Converted SMILES or Converted InChI. For a given query, you can click the "Query Type" bubble to expand it and see the InChIKey that was used instead.

Top Hit Only

By default, CTS-Lite will return only the top hit per query. This setting can be toggled in the settings panel, or by adding the top_hit_only=false parameter to the API request.

For each query, the top hit is determined by ranking the hits on a weighted relevance score:
(0.7 * literature_count) + (0.3 * patent_count)

Anno. Type Count

The "Annotation Type Count" indicates the number of PubChem categories (i.e. Taxonomy, Toxicity, Pharmacology, etc.) that a compound has been annotated with.

Well-researched compounds tend to have 10+ types, with an observed maximum of 20. The "Annotation Type Count" can be used as a supplementary confidence metric when comparing compounds.

Chemical Classification (ClassyFire)

STATUS: ClassyFire is currently unavailable. Chemical classification is temporarily disabled in CTS-Lite. Please try again later, or report a persistent outage to the issue tracker.

CTS-Lite can optionally provide chemical taxonomy classifications from ClassyFire, developed by the Wishart Research Group. Requests with ClassyFire enabled are limited to 1,000 entries.

ClassyFire is disabled by default due to the additional network latency it causes. Enable it from the settings panel, or via the API with the classyfire=true parameter. The stream=true parameter is recommended for ClassyFire requests, to help avoid timeouts.

Each matched compound receives the following ClassyFire fields (some may be empty and therefore omitted):

  • Kingdom (organic vs inorganic, e.g., Organic compounds)
  • Superclass (general structural identifiers, e.g., Organoheterocycli compounds)
  • Class (specific structural features, e.g., Imidazopyrimidines)
  • Subclass (even more specific features, e.g., Purines and purine derivatives)
  • Direct Parent (most specific class (e.g., Xanthines)
  • Description (text description of the compound's chemical class)

If a compound is not found by ClassyFire, or if the ClassyFire service is unavailable, the reason is reported in an error field.

A single query can match many compounds (for example, a molecular formula with top_hit_only=false may return hundreds of hits). To keep latency reasonable, only the top match of each identifier is classified.

Note: ClassyFire adds significant network latency proportional to the number of unique matched compounds in your query.

REST API

Request Formats

To make cURL requests using the REST API, use the following formats:

JSON (Standard):

curl -X POST \ -H "Content-Type: application/json" \ -d '{"queries":"query1 query2 ..."}' \ "cts-lite.metabolomics.us/match"

CSV:

curl -X POST \ -H "Content-Type: application/json" \ -H "Accept: text/csv" \ -d '{"queries":"query1 query2 ..."}' \ "cts-lite.metabolomics.us/match"

Request Parameters

Disable top hit only:

"cts-lite.metabolomics.us/match?top_hit_only=false"

Disable first block matches:

"cts-lite.metabolomics.us/match?first_block_matches=false"

Enable ClassyFire chemical classification:

"cts-lite.metabolomics.us/match?classyfire=true"

Enable NDJSON response streaming (helps prevent timeouts, CSV-incompatible):

"cts-lite.metabolomics.us/match?stream=true"

Response Formats

Example request with default parameters (2 queries): XMBWDFGMSWQBCA-UHDFADDYSA-N will_fail

JSON

[
  {
    "query": "XMBWDFGMSWQBCA-UHDFADDYSA-N",
    "query_type": "inchikey",
    "found_match": true,
    "match_level": "First Block",
    "matches": [
      {
        "identifier": "24841",
        "inchikey": "XMBWDFGMSWQBCA-UHFFFAOYSA-N",
        "inchi": "InChI=1S/HI/h1H",
        "smiles": "I",
        "compound_name": "Hydrogen iodide",
        "molecular_formula": "HI",
        "exact_mass": 127.9123,
        "literature_count": 4430,
        "patent_count": 329042,
        "annotation_type_count": 16
      }
    ],
    "error_message": ""
  },
  {
    "query": "will_fail",
    "query_type": "unidentified",
    "found_match": false,
    "match_level": "",
    "matches": null,
    "error_message": "Invalid query type, could not identify, see documentation"
  }
]

* With ClassyFire enabled, each compound also gets a classyfire JSON object with the six ClassyFire fields and a potential error message

CSV

query,query_type,converted_query,found_match,match_level,error_message,pubchem_cid,inchikey,inchi,smiles,compound_name,molecular_formula,exact_mass,literature_count,patent_count,annotation_type_count
XMBWDFGMSWQBCA-UHDFADDYSA-N,inchikey,,true,First Block,,24841,XMBWDFGMSWQBCA-UHFFFAOYSA-N,InChI=1S/HI/h1H,I,Hydrogen iodide,HI,127.9123,4430,329042,16
will_fail,unidentified,,false,,"Invalid query type, could not identify, see documentation",,,,,,,,,,
                    

* With ClassyFire enabled, seven more columns are appended: the six ClassyFire fields and a potential error message