Database Store

Summary
Database Store
ChemSpider.Database.StoreBase object for interaction with ChemSpider database and extracting data.
Constants
$.ChemSpider.Database.UrlSpecify base URL for getting access to the service and download scripts from.
$.ChemSpider.Web.UrlSpecify base URL to the main ChemSpider website.
Functions
onErrorGlobal OnError handler that will handle all errors occured during the intaraction with ChemSpider side by JSON.ashx service.
getUrlHelper function that concatenate base URL $.ChemSpider.Database.Url with the page and list of parameters
getJsonUrlHelper function that based on getUrl and return URL for the specific JSON.asxh page
simpleSearchRun a simple search on ChemSpider side which tries to interpret a query string as anything it can search by (Synonym, SMILES, InChI, ChemSpider ID etc.)
exactStructureSearchRun identical structure search.
substructureSearchRun substructure search.
substructureSMARTSSearchRun substructure search by SMARTS.
substructureSearchBaseRun substructure search.
similaritySearchRun substructure search.
getSearchStatusGet search status by previously returned request ID.
getSearchResultsReturns search results as list of internal ChemSpider IDs.
waitAndGetSearchResultsWait while the search is finished and return the results as list of internal ChemSpider IDs.
getSearchResultsWithRelevance
waitAndGetSearchResultsWithRelevance
getSearchResultAsCompoundsReturns search results as list of serialized ChemSpider compounds.
waitAndGetSearchResultAsCompoundsWait while the search is finished and return the results as list of serialized ChemSpider compounds.
getCompoundInfoReturns specifiec ChemSpider compounds properties by compound ID.
getMolImageUrlReturns the URL to the 2D image of the molecule with the specific dimentions by ChemSpider ID.
getFileUrlReturns the URL to the file hosted by ChemSpider.
getMolImageUrlBySMILESReturns the URL to the 2D image of the molecule with the specific dimentions by SMILES.
getMolImageUrlByInchiReturns the URL to the 2D image of the molecule with the specific dimentions by SMILES.
getCompoundUrlReturns the URL to the compound page on main ChemSpider website
ChemSpider
Variables
$.ChemSpider.storeGlobal variable that allows to get access to the ChemSpider.Database.Store object from any place of code without initialisation.

ChemSpider.Database.Store

Base object for interaction with ChemSpider database and extracting data.  Based on JSON.ashx REST-full service that returns responses in JSON format.

Summary
Constants
$.ChemSpider.Database.UrlSpecify base URL for getting access to the service and download scripts from.
$.ChemSpider.Web.UrlSpecify base URL to the main ChemSpider website.
Functions
onErrorGlobal OnError handler that will handle all errors occured during the intaraction with ChemSpider side by JSON.ashx service.
getUrlHelper function that concatenate base URL $.ChemSpider.Database.Url with the page and list of parameters
getJsonUrlHelper function that based on getUrl and return URL for the specific JSON.asxh page
simpleSearchRun a simple search on ChemSpider side which tries to interpret a query string as anything it can search by (Synonym, SMILES, InChI, ChemSpider ID etc.)
exactStructureSearchRun identical structure search.
substructureSearchRun substructure search.
substructureSMARTSSearchRun substructure search by SMARTS.
substructureSearchBaseRun substructure search.
similaritySearchRun substructure search.
getSearchStatusGet search status by previously returned request ID.
getSearchResultsReturns search results as list of internal ChemSpider IDs.
waitAndGetSearchResultsWait while the search is finished and return the results as list of internal ChemSpider IDs.
getSearchResultsWithRelevance
waitAndGetSearchResultsWithRelevance
getSearchResultAsCompoundsReturns search results as list of serialized ChemSpider compounds.
waitAndGetSearchResultAsCompoundsWait while the search is finished and return the results as list of serialized ChemSpider compounds.
getCompoundInfoReturns specifiec ChemSpider compounds properties by compound ID.
getMolImageUrlReturns the URL to the 2D image of the molecule with the specific dimentions by ChemSpider ID.
getFileUrlReturns the URL to the file hosted by ChemSpider.
getMolImageUrlBySMILESReturns the URL to the 2D image of the molecule with the specific dimentions by SMILES.
getMolImageUrlByInchiReturns the URL to the 2D image of the molecule with the specific dimentions by SMILES.
getCompoundUrlReturns the URL to the compound page on main ChemSpider website

Constants

$.ChemSpider.Database.Url

Specify base URL for getting access to the service and download scripts from.

$.ChemSpider.Web.Url

Specify base URL to the main ChemSpider website.  Default value http://www.chemspider.com

Functions

onError

onError: function (proc,
xhr,
error,
thrownError)

Global OnError handler that will handle all errors occured during the intaraction with ChemSpider side by JSON.ashx service.  You can use this handler by default or reimplement it according your needs.  Also you can handle all errors inside the function passing error_callback parameter where it is possible

Parameters

procFunction name where the error occured
xhrXmlHttpRequest object with detailed information about error

getUrl

getUrl: function (page,
params)

Helper function that concatenate base URL $.ChemSpider.Database.Url with the page and list of parameters

Parameters

pageRelative path to the page
paramsList of parameters
var url = $.ChemSpider.store.getUrl('JSON.asxh', {'op': 'SimpleSearch', 'searchOptions.QueryText': 'Aspirin'});

getJsonUrl

getJsonUrl: function (params)

Helper function that based on getUrl and return URL for the specific JSON.asxh page

Parameters

paramsList of parameters
var url = $.ChemSpider.store.getJsonUrl({'op': 'SimpleSearch', 'searchOptions.QueryText': 'Aspirin'});

simpleSearch

simpleSearch: function (query,
callback,
error_callback)

Run a simple search on ChemSpider side which tries to interpret a query string as anything it can search by (Synonym, SMILES, InChI, ChemSpider ID etc.)

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

queryQuery string (Synonym, SMILES, InChI, ChemSpider ID etc.)
callbackCallback function that will be called if function finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.simpleSearch('Aspirin', function(rid) {
//  Request ID will be returned through 'rid' parameter.
//  This 'rid' should be used later for further actions...
});

exactStructureSearch

exactStructureSearch: function (molecule,
callback,
error_callback)

Run identical structure search.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

moleculeMolecule for search as SMILES
callbackCallback function that will be called if function finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.exactStructureSearch('CC(=O)Oc1ccccc1C(=O)O', function(rid) {
//  Request ID will be returned through 'rid' parameter.
//  This 'rid' should be used later for further actions...
});

substructureSearch

substructureSearch: function (molecule,
callback,
error_callback)

Run substructure search.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

moleculeMolecule for search as SMILES
callbackCallback function that will be called if function finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.substructureSearch('CC(=O)Oc1ccccc1C(=O)O', function(rid) {
//  Request ID will be returned through 'rid' parameter.
//  This 'rid' should be used later for further actions...
});

substructureSMARTSSearch

substructureSMARTSSearch: function (smarts,
callback,
error_callback)

Run substructure search by SMARTS.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

smartsSMARTS string to search for
callbackCallback function that will be called if function finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.substructureSMARTSSearch('NC(=N)c(cc1)ccc1C', function(rid) {
//  Request ID will be returned through 'rid' parameter.
//  This 'rid' should be used later for further actions...
});

substructureSearchBase

substructureSearchBase: function (params,
callback,
error_callback)

Run substructure search.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

paramslist of parameters sent through the request
callbackCallback function that will be called if function finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.substructureSearch('CC(=O)Oc1ccccc1C(=O)O', function(rid) {
//  Request ID will be returned through 'rid' parameter.
//  This 'rid' should be used later for further actions...
});

similaritySearch

similaritySearch: function (molecule,
threshold,
type,
callback,
error_callback)

Run substructure search.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

moleculeMolecule for search as SMILES
thresholdSimilarity threshold.  Double value from 0 to 1.  99% similarity means 0.99 in this case; 80% should be as 0.8
typeSimilarity search type.  Posible values: {Tanimoto, Tversky, Euclidian}
callbackCallback function that will be called if function finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.substructureSearch('CC(=O)Oc1ccccc1C(=O)O', 0.99, 'Tanimoto', function(rid) {
//  Request ID will be returned through 'rid' parameter.
//  This 'rid' should be used later for further actions...
});

getSearchStatus

getSearchStatus: function (rid,
callback,
error_callback)

Get search status by previously returned request ID.  To get more information about status object, please check here.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

ripRequest ID returned from any search functions.
callbackCallback function that will be called if finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.getSearchStatus(rid, function(status) {
//  rid - request ID that was returned from any search function
//  status - current search status
});

getSearchResults

getSearchResults: function (rid,
callback,
error_callback)

Returns search results as list of internal ChemSpider IDs.  Be shure that the search already finished and status is ResultReady.  See also waitAndGetSearchResults function.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

ripRequest ID returned from any search functions.
callbackCallback function that will be called if finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.getSearchResults(rid, function(compounds) {
//  rid - request ID that was returned from any search function
//  compounds - list of ChemSpider IDs
});

waitAndGetSearchResults

waitAndGetSearchResults: function (rid,
callback,
error_callback)

Wait while the search is finished and return the results as list of internal ChemSpider IDs.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

ripRequest ID returned from any search functions.
callbackCallback function that will be called if finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.waitAndGetSearchResults(rid, function(compounds) {
//  rid - request ID that was returned from any search function
//  compounds - list of ChemSpider IDs
});

getSearchResultsWithRelevance

getSearchResultsWithRelevance: function (rid,
callback,
error_callback)
Returns search results as list of internal ChemSpider IDs with one additional columnrelevance.  Records are sorted by relevance.  Be shure that the search already finished and status is ResultReady.  See also waitAndGetSearchResults function.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

ripRequest ID returned from any search functions.
callbackCallback function that will be called if finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.getSearchResultsWithRelevance(rid, function(compounds) {
//  rid - request ID that was returned from any search function
//  compounds - list pairs: ChemSpider ID and Relevance
});

waitAndGetSearchResultsWithRelevance

waitAndGetSearchResultsWithRelevance: function (rid,
callback,
error_callback)
Wait while the search is finished and return the results as list of internal ChemSpider IDs with one additional columnrelevance.  Records are sorted by relevance.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

ripRequest ID returned from any search functions.
callbackCallback function that will be called if finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.waitAndGetSearchResultsWithRelevance(rid, function(compounds) {
//  rid - request ID that was returned from any search function
//  compounds - list pairs: ChemSpider IDs and Relevance
});

getSearchResultAsCompounds

getSearchResultAsCompounds: function (rid,
serfilter,
callback,
error_callback)

Returns search results as list of serialized ChemSpider compounds.  Be shure that the search already finished and status is ResultReady.  See also waitAndGetSearchResultAsCompounds function.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

ripRequest ID returned from any search functions.
serfilterSerialization filter.  Specify what compound’s properties should be included to the response.  If this parameter is ‘null’ then all properties will be serialized.
callbackCallback function that will be called if finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.getSearchResultAsCompounds(rid, 'Compound[CSID|MF|Name|Mol|Synonyms]', function(compounds) {
//  rid - request ID that was returned from any search function
//  Compound[CSID|MF|Name|Mol|Synonyms] - serialize only CSID, Molecular Formula, MOL file and Synonyms list properties
//  compounds - list of ChemSpider compounds as JSON objects
});

Serealization of all compound’s properties is pretty slow operation (especially if you have search results with hundreds compounds) and in order to speed up this process we suggest to include to the response only the properties that you really need.  You can find the whole list of compound’s properties for serialization here

waitAndGetSearchResultAsCompounds

waitAndGetSearchResultAsCompounds: function (rid,
serfilter,
callback,
error_callback)

Wait while the search is finished and return the results as list of serialized ChemSpider compounds.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

ripRequest ID returned from any search functions.
serfilterSerialization filter.  Specify what compound’s properties should be included to the response.  If this parameter is ‘null’ then all properties will be serialized.
callbackCallback function that will be called if finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.waitAndGetSearchResultAsCompounds(rid, 'Compound[CSID|MF|Name|Mol|Synonyms]', function(compounds) {
//  rid - request ID that was returned from any search function
//  Compound[CSID|MF|Name|Mol|Synonyms] - serialize only CSID, Molecular Formula, MOL file and Synonyms list properties
//  compounds - list of ChemSpider compounds as JSON objects
});

Serealization of all compound’s properties is pretty slow operation (especially if you have search results with hundreds compounds) and in order to speed up this process we suggest to include to the response only the properties that you really need.  You can find the whole list of compound’s properties for serialization here

getCompoundInfo

getCompoundInfo: function (csid,
serfilter,
callback,
error_callback)

Returns specifiec ChemSpider compounds properties by compound ID.  This function mostly used to get access to the properties assigned to compounds.

This function doesn’t return anything as return parameter, but calls callback function in case of succeess or error_callback in case of any problems.  If no error_callback passed to the function, default onError handler will be used.

Parameters

csidChemSpider ID that was returned from search results for example or already known ID for some reason.
serfilterSerialization filter.  Specify what compound’s properties should be included to the response.  If this parameter is ‘null’ then all properties will be serialized.
callbackCallback function that will be called if finished successfully
error_callbackCallback function that will be called if some errors occure
$.ChemSpider.store.getCompoundInfo(2157, 'Compound[CSID|MF|Name|Mol|Identifiers]', function(compound) {
//  2157 - ChemSPider ID fro Aspirin compound
//  Compound[CSID|MF|Name|Mol|Identifiers] - serialize only CSID, Molecular Formula, MOL file and Identifiers list properties
//  compound - ChemSpider compound as JSON object with requested properties
});

Serealization of all compound’s properties is pretty slow operation and in order to speed up this process we suggest to include to the response only the properties that you really need.  You can find the whole list of compound’s properties for serialization here

getMolImageUrl

getMolImageUrl: function (csid,
width,
height)

Returns the URL to the 2D image of the molecule with the specific dimentions by ChemSpider ID.

Parameters

csidChemSpider compound ID
widthImage width
heightImage height
var url = $.ChemSpider.store.getMolImageUrl(2157, 200, 200);

getFileUrl

getFileUrl: function (params)

Returns the URL to the file hosted by ChemSpider.

Parameters

paramsparameters that describes file to return.
var url = $.ChemSpider.store.getFileUrl({type: 'blob', id: 6182});

getMolImageUrlBySMILES

getMolImageUrlBySMILES: function (smiles,
width,
height)

Returns the URL to the 2D image of the molecule with the specific dimentions by SMILES.

Parameters

smilesSMILES of the molecule that should be rendered
widthImage width
heightImage height
var url = $.ChemSpider.store.getMolImageUrlBySMILES('CC(=O)Oc1ccccc1C(=O)O', 200, 200);

getMolImageUrlByInchi

getMolImageUrlByInchi: function (inchi,
width,
height)

Returns the URL to the 2D image of the molecule with the specific dimentions by SMILES.

Parameters

inchiInChi of the molecule that should be rendered
widthImage width
heightImage height
var url = $.ChemSpider.store.getMolImageUrlByInchi('InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12)', 200, 200);

getCompoundUrl

getCompoundUrl: function (csid)

Returns the URL to the compound page on main ChemSpider website

Parameters

csidChemSpider compound ID.
var url = $.ChemSpider.store.getCompoundUrl(2157);

ChemSpider

Summary
Variables
$.ChemSpider.storeGlobal variable that allows to get access to the ChemSpider.Database.Store object from any place of code without initialisation.

Variables

$.ChemSpider.store

$.ChemSpider.store

Global variable that allows to get access to the ChemSpider.Database.Store object from any place of code without initialisation.

onError: function (proc,
xhr,
error,
thrownError)
Global OnError handler that will handle all errors occured during the intaraction with ChemSpider side by JSON.ashx service.
getUrl: function (page,
params)
Helper function that concatenate base URL $.ChemSpider.Database.Url with the page and list of parameters
Specify base URL for getting access to the service and download scripts from.
getJsonUrl: function (params)
Helper function that based on getUrl and return URL for the specific JSON.asxh page
simpleSearch: function (query,
callback,
error_callback)
Run a simple search on ChemSpider side which tries to interpret a query string as anything it can search by (Synonym, SMILES, InChI, ChemSpider ID etc.)
exactStructureSearch: function (molecule,
callback,
error_callback)
Run identical structure search.
substructureSearch: function (molecule,
callback,
error_callback)
Run substructure search.
substructureSMARTSSearch: function (smarts,
callback,
error_callback)
Run substructure search by SMARTS.
substructureSearchBase: function (params,
callback,
error_callback)
Run substructure search.
similaritySearch: function (molecule,
threshold,
type,
callback,
error_callback)
Run substructure search.
getSearchStatus: function (rid,
callback,
error_callback)
Get search status by previously returned request ID.
getSearchResults: function (rid,
callback,
error_callback)
Returns search results as list of internal ChemSpider IDs.
waitAndGetSearchResults: function (rid,
callback,
error_callback)
Wait while the search is finished and return the results as list of internal ChemSpider IDs.
getSearchResultsWithRelevance: function (rid,
callback,
error_callback)
waitAndGetSearchResultsWithRelevance: function (rid,
callback,
error_callback)
getSearchResultAsCompounds: function (rid,
serfilter,
callback,
error_callback)
Returns search results as list of serialized ChemSpider compounds.
waitAndGetSearchResultAsCompounds: function (rid,
serfilter,
callback,
error_callback)
Wait while the search is finished and return the results as list of serialized ChemSpider compounds.
getCompoundInfo: function (csid,
serfilter,
callback,
error_callback)
Returns specifiec ChemSpider compounds properties by compound ID.
getMolImageUrl: function (csid,
width,
height)
Returns the URL to the 2D image of the molecule with the specific dimentions by ChemSpider ID.
getFileUrl: function (params)
Returns the URL to the file hosted by ChemSpider.
getMolImageUrlBySMILES: function (smiles,
width,
height)
Returns the URL to the 2D image of the molecule with the specific dimentions by SMILES.
getMolImageUrlByInchi: function (inchi,
width,
height)
Returns the URL to the 2D image of the molecule with the specific dimentions by SMILES.
getCompoundUrl: function (csid)
Returns the URL to the compound page on main ChemSpider website
$.ChemSpider.store
Global variable that allows to get access to the ChemSpider.Database.Store object from any place of code without initialisation.