ZINC15:Syntax: Difference between revisions

From DISI
Jump to navigation Jump to search
No edit summary
No edit summary
 
(34 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The general form of a ZINC 15 api request is
ZINC 15 uses a uniform set of rules to interpret the URL allowing both web pages and a machine-readable application programming interface (API).  This page describes both.


'''http[s]://host:port/reference-table/format:column1,column2,...columnN/query-specification'''
{{TOCright}}


We take up each element in turn.  
= Overview =
ZINC15 queries for all resource types can be formulated as HTTP requests using a consistent URL syntax. The syntax is consistent for both interactive (browser-based) and API (script-based) queries. The API downloads are triggered by specifying a download format and, optionally, a list of output fields to include.


- We support both http and https protocols.  
All URLs will be provided relative to [//zinc15.docking.org zinc15.docking.org], thus /substances/ implies [http://zinc15.docking.org/substances/ zinc15.docking.org/substances/].
- host name on request
- port number on request


= reference-table =  
= Syntax =
There is one reference table per ZINC api request. Each row in the output corresponds to one row in the reference-table.  Reference tables are always plurals, indicating that the result is always a selection from among the rows in the reference-table. The supported reference-tables are:


{| class="wikitable"
The full syntax of a query is defined as:
|-
<pre style="overflow-x: scroll">
! table name !! Description !! Notes/Links
/<RESOURCE>[/<IDENTIFIER>[/<RELATION>]][/subsets/<SUBSET>[+<SUBSET>...]][/having/[no-]<EXT_RELATION>[+[no-]<EXT_RELATION>...]][/subsets/[<EXT_RELATION>.]<RELATION_SUBSET>+[[<EXT_RELATION>.]<RELATION_SUBSET>...]](/[<VIEW>.html]|.<FORMAT>[:<OUTPUT_FIELD>[+<OUTPUT_FIELD>...]])[?<OPTION_NAME>=<OPTION_VALUE>|<QUERY_FIELD>[-<OPERATOR>[-<OPERATOR_ARG>...]]=<FIELD_CONSTRAINT>[&<OPTION_NAME>=<OPTION_VALUE>|<QUERY_FIELD>[-<OPERATOR>[-<OPERATOR_ARG>...]]=<FIELD_CONSTRAINT>...]]
|-
</pre>
|  substances || substance table || notes about substance table
|-
| ecfp4s  || lala || lala
|-
| catalogitems || lala || asdf
|-
| catalogs || asdfasdf || sdfsdfdaf
|-
| protomers || qwer34 || seradsf
|-
| genes || sdfasfd || sadfasdf
|-
| targets || asdfasdf || asdfasdf sa
|-
| activities || sadfasfsd || asdfasfd
|-
| organisms ||asdf asdf || asdfasfd sadf
|}


Historical note: In ZINC 12, the reference-table was always substances, and thus the result of any query was always a set of molecules. A few reports such as vendor and target listings were available via the webpages, but were not supported by the API.  This is a substantial change that appeared first in ZINC 15.
More Concisely, this can be written as:
<pre style="overflow-x: scroll">
/<Root>[/<Subsets>][/<Existential>[/<Ext. Subsets>]]<Formatting>[?[<Constraints>][<Options>]]
</pre>


= Format =
Broken down into individual components:
We support the following formats


{| class="wikitable"
{| class="wikitable"
|-
|-  
! format !! Description !! options/links
! Syntax
|-
! Name
json || substance table || notes about substance table
! Explanation
|-
! Example
| txt || lala || lala
! Notes
|-
|-
| csv || lala || asdf
| <RESOURCE>[/<IDENTIFIER>[/<RELATION>]]
|-
  | ('''Root''') <br>Query Root
| xls || asdfasdf || sdfsdfdaf
| Defines where the query should be performed: either on the whole resource or only those related to another, single resource.
|-
| [//zinc15.docking.org/trials/NCT00001251/substances/ /trials/NCT00001251/substances]
| tsv || qwer34 || seradsf
| Valid values for <IDENTIFIER> and <RELATION> parts of the query root are defined separate for each resource.
|-
|-
| xml || sdfasfd || sadfasdf
| subsets/<SUBSET>[+<SUBSET>...]
  | ('''Subsets''') <br>Query Subsets
| Applies one or more named, predefined constraints to the query.
| [//zinc15.docking.org/substances/subsets/fda+for-sale/ .../subsets/fda+for-sale/]
| Subsets are defined separately for each resource. Some subsets are disjoint, so it's possible to accidentally construct null queries
|-
| having/[no-]<EXT_RELATION>[+[no-]<EXT_RELATION>...]
| ('''Existential''') <br>Existential Requirements
| Applies existential (or non-existential with the "no-" prefix) constraints based on on the results of the query
| [//zinc15.docking.org/genes/having/no-protomers/ .../having/no-protomers/]
| The available relations depend on the resultant resource, which is not necessarily the same as the root resource
|-
| subsets/[<EXT_RELATION>.]<RELATION_SUBSET>+[[<EXT_RELATION>.]<RELATION_SUBSET>...]
| ('''Ext. Subsets''') <br>Existential Relation Subsets
| Applies subset requirements to the **existential relation requirement** (see above) of the query
| [//zinc15.docking.org/substances/having/trials/subsets/cancer/ .../subsets/cancer/]
| The relation subsets are completely independent of the query subsets, and valid values depend on the type of the existential resource. When multiple existential relations are specified, the subsets must be prefixed with "<EXT_RELATION>." to identify which they apply to.
|-  
| /[<VIEW>.html] OR<br> .<FORMAT>[:<OUTPUT_FIELD>[+<OUTPUT_FIELD>...]]
| ('''Formatting''') <br>Formatting Options
| Dictates how the result of a query will be returned. If <FORMAT> is specified the result will be sent as a download. If a <VIEW> is specified the result will be rendered as HTML. If neither is provided (just "/") the "**Accept**"  header will be interrogated to determine the requested format, which defaults to HTML.
| [//zinc15.docking.org/majorclasses.json%3Apublic_identifier+name+num_genes+num_substances .json:public_identifier+name +num_genes+num_substances]
| Valid views (currently) include table or tile. The default is always tile. Valid [[ZINC15:Formats]] are explained in the wiki. Valid <OUTPUT_FIELD>s depend on the specific resource being requested, and  can be found on the resource help pages.
|}
|}


== Query Root ==


= Columns =
There are three basic types of queries supported by ZINC15.
The result contains the specified columns in the output.  If the column is in the reference-table, it is specified without a table specfification, otherwise, the column specification must be of the form table.item.
 
The following items are supported in each of the tables.  
 


{| class="wikitable"
{| class="wikitable"
|-
|-  
! table name !! Description !! Notes/Links
! Kind
|-
! Syntax
| substances || substance table || notes about substance table
! Description  
|-
! Example
| ecfp4s || lala || lala
|-  
|-
  | Full Resource Listing
| catalogitems || lala || asdf
| /<RESOURCE>
|-
  | Performs the query on all <RESOURCE>s
| catalogs || asdfasdf || sdfsdfdaf
| [//zinc15.docking.org/genes/ /genes]
|-
|-  
| protomers || qwer34 || seradsf
| Single Resource Lookup
|-
| /<RESOURCE>/<IDENTIFIER>
| genes || sdfasfd || sadfasdf
| Retrieves information about a specific <RESOURCE> instance identified by <IDENTIFIER>
|-
| [//zinc15.docking.org/genes/ADRB1 /genes/ADRB1]
| targets || asdfasdf || asdfasdf sa
|-  
|-
| Single Resource Relation
| activities || sadfasfsd || asdfasfd
| /<RESOURCE>/<IDENTIFIER>/<RELATION>
|-
| Performs the query on only resources that are linked to a specific instance of a <RESOURCE> identified by <IDENTIFIER> via the <RELATION> relationship. The type of the result will depend on the taret of <RELATION> (see below).
| organisms ||asdf asdf || asdfasfd sadf
| [//zinc15.docking.org/genes/ADRB1/substances/ /genes/ADRB1/substances]
|}
|}
 
 
 
Objects from among these may be specified as part of a query_specification.
 


=== Parameters ===


{| class="wikitable"
{| class="wikitable"
|-
|-  
! table name !! Description !! Notes/Links
! Name
|-
! Meaning
| substances || sub_id, structure, inchikey, up_date, logp, tpsa, hbd, hba || notes about substance table
! Example
|-
! Example URL
| structure || mwt, logp, tpsa, hba, hbd, num_atoms, num_heavy_atoms, rotatable_bonds, num_hetero_atoms, num_rings, inchi || lala
! Options
|-
|-  
| protomers || prot_id, sub_id_fk, desolv_apol, desolv_pol, net_charge || asdf
  | <RESOURCE>
|-
| The name of a ZINC15 resource.
| catalogs || cat_id, name, short_name, purchasable, free, version, updated, bb, np, drug || sdfsdfdaf
  | catalogs
|-
| [//zinc15.docking.org/catalogs/ /<b>catalogs</b>/]
| catalogitems || sub_id_fk, cat_id_fk, supplier_code, depleted || seradsf
| [[ZINC15:Resources|Wiki Explanation of Resources]] [//zinc15.docking.org/help/resources/ ZINC15 Meta-resource]
|-
|-  
| genes || short_name || sadfasdf
| <IDENTIFIER>
|-
| The unique identifier (key) for a specific resource instance.
| targets || swissprot, uniprot, target, gene, affinity || asdfasdf sa
| ZINC000000000053
|-
| [//zinc15.docking.org/substances/ZINC000000000053 /substances/<b>ZINC000000000053</b>/]
| activities || affinitynM, target, gene, organism || asdfasfd
| The identifier column is listed on each resources' "help" page (e.g. [//zinc15.docking.org/substances/help/]) and can also always be accessed via the `public_identifier` attribute of a resource instance.
|-
|-
| organisms ||asdf asdf || asdfasfd sadf
| <RELATION>
|}
| The name of a relation defined on <RESOURCE> objects.
| activities
| [//zinc15.docking.org/substances/ZINC000000000053/activities /substances/ZINC000000000053/<b>activities</b>]
| The name and type of each resources' relations is defined on the "help" page (e.g. [//zinc15.docking.org/substances/help/])
|}


= Query operators =
Note that a query rooted on /catalog/sial/items will not return **catalogs**, but instead **catitems**, as the catalog relation named **items** returns **catitem** resources. This can be seen on the [//zinc15.docking.org/catalogs/help Catalog Help Page].




{| class="wikitable"
The items in [ square brackets ] are optional. The items in < angled braces > are each described below.
|-
! operator !! Description !! synonyms
|-
| @> || lala || contains
|-
| <@ || lala || contained in
|-
| = || equals || eq
|-
| < || less than || lt
|-
| > || greater than || gt
|-
| <= || less than or equal || le
|-
| >= || greater than or equal || ge
|-
| between || sadfasfsd || asdfasfd
|-
| like, is, not , startswith, endswith, similar to ||asdf asdf || asdfasfd sadf
|}


= NP, Drug and BB =
* <RESOURCE> is an object type, such as molecules, catalogs or genes, and are fully described here: [[ZINC15:Resources]]


* <FORMAT> is one of the supported formats, such as smi, sdf, csv, fully described here:  [[ZINC15:Formats]]. If a format is omitted, a webpage is implicitly requested.


{| class="wikitable"
* <FIELDS> are individual properties, including calculated ones, and are described together with the [[ZINC15:Resources]] to which they belong.
|-
[[ZINC15:Properties]] Not all properties make sense in all resource contexts. [[ZINC15:examples]] are provided. Each resource has default fields, if none are specified.
! quality !! values !! Notes/Links
|-
| NP || 0=unknown, 1=biogenic, 2=metabolite, 3=endogenous human metabolite || lala
|-
| Drug  || 0=unknown, 1=annotated catalog, 2=bioactive, 4=bioactive in vitro < 1uM, 5=bioactive in cells <1uM, 6=in man, 8=world drug, 10=fda approved || lala
|-
| BB || f=not bb, t=bb || asdf
|}
 


= Similarity and Substructure
* <ENDPOINT> is one of (tile, table, detail, etc.) (only available if the underlying template exists); where items in [ square brackets ] are optional, and:


  .../substance.structure similarto c1ccccc1CCCOC within .7 using tanimoto
  [[ZINC15:Variants]].


/substance/txt:zinc_id/substance isa metabolite
* <PREDICATE_LIST> is a query string, one or more of <PREDICATE> delimited by &<PREDICATE> is <ATTRIBUTE>[:<OPERATOR>[;<OPERATOR_ARGS>]]=<THRESHOLD>


/substances/txt:zinc_id?sort=substance.structure+near+c1ccccc1CCNC+using+dice
* [[ZINC15:Page Controls]] are optional, and are used to qualify how a search is to be performed and formatted for the page.


* [[ZINC15:Query operators]]


* https is currently not supported, but it will be.


Closest purchasable metabolite
= Reserved words =
select s.sub_id, s.smiles, tanimoto_sml(f.data,   bfp_from_binary_text('\x804300004000200080400000800000008220800040000120008002002011000010040081010000002840400009d040048000020200001a404100000002000040')), short_name from fingerprints.ecfp4_data as f join fingerprints.ecfp4_id on ecfp4_id=f.ecfp4_fk join substance as s on s.ecfp4_fk=ecfp4_id join catalog_item on sub_id_fk=s.sub_id join catalog on cat_id_fk=cat_id where f.ecfp4_fk < 1000000 and purchasable > 30 order by bfp_from_binary_text('\x804300004000200080400000800000008220800040000120008002002011000010040081010000002840400009d040048000020200001a404100000002000040') <%> f.data limit 5;
* list, tile, subsets, help, overview  - these have special meaning in the URL, and can never be the names of resources or their columns.  


= Examples =
We illustrate the use of the website and the API with [[ZINC15:examples]].


Back to [[ZINC15]]
[[Category:API]]
[[Category:API]]
[[Category:ZINC]]
[[Category:ZINC15]]

Latest revision as of 01:01, 5 January 2019

ZINC 15 uses a uniform set of rules to interpret the URL allowing both web pages and a machine-readable application programming interface (API). This page describes both.

Overview

ZINC15 queries for all resource types can be formulated as HTTP requests using a consistent URL syntax. The syntax is consistent for both interactive (browser-based) and API (script-based) queries. The API downloads are triggered by specifying a download format and, optionally, a list of output fields to include.

All URLs will be provided relative to zinc15.docking.org, thus /substances/ implies zinc15.docking.org/substances/.

Syntax

The full syntax of a query is defined as:

/<RESOURCE>[/<IDENTIFIER>[/<RELATION>]][/subsets/<SUBSET>[+<SUBSET>...]][/having/[no-]<EXT_RELATION>[+[no-]<EXT_RELATION>...]][/subsets/[<EXT_RELATION>.]<RELATION_SUBSET>+[[<EXT_RELATION>.]<RELATION_SUBSET>...]](/[<VIEW>.html]|.<FORMAT>[:<OUTPUT_FIELD>[+<OUTPUT_FIELD>...]])[?<OPTION_NAME>=<OPTION_VALUE>|<QUERY_FIELD>[-<OPERATOR>[-<OPERATOR_ARG>...]]=<FIELD_CONSTRAINT>[&<OPTION_NAME>=<OPTION_VALUE>|<QUERY_FIELD>[-<OPERATOR>[-<OPERATOR_ARG>...]]=<FIELD_CONSTRAINT>...]]

More Concisely, this can be written as:

/<Root>[/<Subsets>][/<Existential>[/<Ext. Subsets>]]<Formatting>[?[<Constraints>][<Options>]]

Broken down into individual components:

Syntax Name Explanation Example Notes
<RESOURCE>[/<IDENTIFIER>[/<RELATION>]] (Root)
Query Root
Defines where the query should be performed: either on the whole resource or only those related to another, single resource. /trials/NCT00001251/substances Valid values for <IDENTIFIER> and <RELATION> parts of the query root are defined separate for each resource.
subsets/<SUBSET>[+<SUBSET>...] (Subsets)
Query Subsets
Applies one or more named, predefined constraints to the query. .../subsets/fda+for-sale/ Subsets are defined separately for each resource. Some subsets are disjoint, so it's possible to accidentally construct null queries
having/[no-]<EXT_RELATION>[+[no-]<EXT_RELATION>...] (Existential)
Existential Requirements
Applies existential (or non-existential with the "no-" prefix) constraints based on on the results of the query .../having/no-protomers/ The available relations depend on the resultant resource, which is not necessarily the same as the root resource
subsets/[<EXT_RELATION>.]<RELATION_SUBSET>+[[<EXT_RELATION>.]<RELATION_SUBSET>...] (Ext. Subsets)
Existential Relation Subsets
Applies subset requirements to the **existential relation requirement** (see above) of the query .../subsets/cancer/ The relation subsets are completely independent of the query subsets, and valid values depend on the type of the existential resource. When multiple existential relations are specified, the subsets must be prefixed with "<EXT_RELATION>." to identify which they apply to.
/[<VIEW>.html] OR
.<FORMAT>[:<OUTPUT_FIELD>[+<OUTPUT_FIELD>...]]
(Formatting)
Formatting Options
Dictates how the result of a query will be returned. If <FORMAT> is specified the result will be sent as a download. If a <VIEW> is specified the result will be rendered as HTML. If neither is provided (just "/") the "**Accept**" header will be interrogated to determine the requested format, which defaults to HTML. .json:public_identifier+name +num_genes+num_substances Valid views (currently) include table or tile. The default is always tile. Valid ZINC15:Formats are explained in the wiki. Valid <OUTPUT_FIELD>s depend on the specific resource being requested, and can be found on the resource help pages.


Query Root

There are three basic types of queries supported by ZINC15.

Kind Syntax Description Example
Full Resource Listing /<RESOURCE> Performs the query on all <RESOURCE>s /genes
Single Resource Lookup /<RESOURCE>/<IDENTIFIER> Retrieves information about a specific <RESOURCE> instance identified by <IDENTIFIER> /genes/ADRB1
Single Resource Relation /<RESOURCE>/<IDENTIFIER>/<RELATION> Performs the query on only resources that are linked to a specific instance of a <RESOURCE> identified by <IDENTIFIER> via the <RELATION> relationship. The type of the result will depend on the taret of <RELATION> (see below). /genes/ADRB1/substances

Parameters

Name Meaning Example Example URL Options
<RESOURCE> The name of a ZINC15 resource. catalogs /catalogs/ Wiki Explanation of Resources ZINC15 Meta-resource
<IDENTIFIER> The unique identifier (key) for a specific resource instance. ZINC000000000053 /substances/ZINC000000000053/ The identifier column is listed on each resources' "help" page (e.g. [1]) and can also always be accessed via the `public_identifier` attribute of a resource instance.
<RELATION> The name of a relation defined on <RESOURCE> objects. activities /substances/ZINC000000000053/activities The name and type of each resources' relations is defined on the "help" page (e.g. [2])

Note that a query rooted on /catalog/sial/items will not return **catalogs**, but instead **catitems**, as the catalog relation named **items** returns **catitem** resources. This can be seen on the Catalog Help Page.


The items in [ square brackets ] are optional. The items in < angled braces > are each described below.

  • <RESOURCE> is an object type, such as molecules, catalogs or genes, and are fully described here: ZINC15:Resources
  • <FORMAT> is one of the supported formats, such as smi, sdf, csv, fully described here: ZINC15:Formats. If a format is omitted, a webpage is implicitly requested.
  • <FIELDS> are individual properties, including calculated ones, and are described together with the ZINC15:Resources to which they belong.

ZINC15:Properties Not all properties make sense in all resource contexts. ZINC15:examples are provided. Each resource has default fields, if none are specified.

  • <ENDPOINT> is one of (tile, table, detail, etc.) (only available if the underlying template exists); where items in [ square brackets ] are optional, and:
ZINC15:Variants.
  • <PREDICATE_LIST> is a query string, one or more of <PREDICATE> delimited by &<PREDICATE> is <ATTRIBUTE>[:<OPERATOR>[;<OPERATOR_ARGS>]]=<THRESHOLD>
  • ZINC15:Page Controls are optional, and are used to qualify how a search is to be performed and formatted for the page.
  • https is currently not supported, but it will be.

Reserved words

  • list, tile, subsets, help, overview - these have special meaning in the URL, and can never be the names of resources or their columns.

Examples

We illustrate the use of the website and the API with ZINC15:examples.

Back to ZINC15