pyclassyfire API

pyclassyfire.client module

A client for the ClassyFire API which enables efficient querying with chemical database files

pyclassyfire.client.get_chemont_node(chemontid)[source]

Return data for the TaxNode with ID chemontid.

Parameters:chemontid (str) – the ChemOnt ID of the entity.
Returns:The classification results for the entity as json.
Return type:str
>>> get_chemont_node('CHEMONTID:0004253')
pyclassyfire.client.get_entity(inchikey, return_format='json')[source]

Given a InChIKey for a previously queried structure, fetch the classification results.

Parameters:
  • inchikey (str) – An InChIKey for a previously calculated chemical structure
  • return_format (str) – desired return format. valid types are json, csv or sdf
Returns:

query information

Return type:

str

>>> get_entity("ATUOYWHBWRKTHZ-UHFFFAOYSA-N", 'csv')
>>> get_entity("ATUOYWHBWRKTHZ-UHFFFAOYSA-N", 'json')
>>> get_entity("ATUOYWHBWRKTHZ-UHFFFAOYSA-N", 'sdf')
pyclassyfire.client.get_results(query_id, return_format='json')[source]

Given a query_id, fetch the classification results.

Parameters:
  • query_id (str) – A numeric query id returned at time of query submission
  • return_format (str) – desired return format. valid types are json, csv or sdf
Returns:

query information

Return type:

str

>>> get_results('595535', 'csv')
>>> get_results('595535', 'json')
>>> get_results('595535', 'sdf')
pyclassyfire.client.iupac_query(compound, label='pyclassyfire')[source]

Submit a IUPAC compound name to the ClassyFire service for evaluation and receive a id which can be used to used to collect results

Parameters:
  • compound (str) – The line delimited compound names. Optionally a tab-separated id may be prepended for each compound.
  • label – A label for the query
Returns:

A query ID number

Return type:

int

>>> iupac_query('ethane', 'iupac_test')
>>> iupac_query('C001\tethane\nC002\tethanol', 'iupac_test')
pyclassyfire.client.sdf_query(inpath, outpath=None)[source]

Given a path to a compound set in a sdf file, annotate all compounds and write results as attributes in a sdf file.

Parameters:
  • inpath (str) – path to compound file to be annotated
  • outpath (str) – Path to desired output location
>>> sdf_query('/sdf_data.sdf')
pyclassyfire.client.structure_query(compound, label='pyclassyfire')[source]

Submit a compound information to the ClassyFire service for evaluation and receive a id which can be used to used to collect results

Parameters:
  • compound (str) – The compound structures as line delimited inchikey or smiles. Optionally a tab-separated id may be prepended for each structure.
  • label – A label for the query
Returns:

A query ID number

Return type:

int

>>> structure_query('CCC', 'smiles_test')
>>> structure_query('InChI=1S/C3H4O3/c1-2(4)3(5)6/h1H3,(H,5,6)')
pyclassyfire.client.tabular_query(inpath, structure_key, dialect='excel', outpath=None, outfields=('taxonomy', 'description', 'substituents'))[source]

Given a path to a compound set in tabular form (comma or tab delimited) annotate all compounds and write results to an expanded table.

Parameters:
  • inpath (str) – path to compound file to be annotated
  • structure_key (str) – column heading which contains the compounds InChIKey or SMILES
  • dialect (str) – dialect for parsing table (generally ‘excel’ for csv, ‘excel-tab’ for tsv)
  • outpath (str) – Path to desired output location
  • outfields (tuple(string)) – Fields to append to table from ClassyFire output
>>> tabular_query('/tabulated_data.tsv', 'structure', 'excel-tab')