API documentation

This part of the documentation is automatically generated from the CIRpy source code and comments.

Resolve

cirpy.resolve(input, representation, resolvers=None, get3d=False, **kwargs)

Resolve input to the specified output representation.

Parameters:
  • input (string) – Chemical identifier to resolve
  • representation (string) – Desired output representation
  • resolvers (list(string)) – (Optional) Ordered list of resolvers to use
  • get3d (bool) – (Optional) Whether to return 3D coordinates (where applicable)
Returns:

Output representation or None

Return type:

string or None

Raises:
  • HTTPError – if CIR returns an error code
  • ParseError – if CIR response is uninterpretable

Query

cirpy.query(input, representation, resolvers=None, get3d=False, tautomers=False, **kwargs)

Get all results for resolving input to the specified output representation.

Parameters:
  • input (string) – Chemical identifier to resolve
  • representation (string) – Desired output representation
  • resolvers (list(string)) – (Optional) Ordered list of resolvers to use
  • get3d (bool) – (Optional) Whether to return 3D coordinates (where applicable)
  • tautomers (bool) – (Optional) Whether to return all tautomers
Returns:

List of resolved results

Return type:

list(Result)

Raises:
  • HTTPError – if CIR returns an error code
  • ParseError – if CIR response is uninterpretable

Result

class cirpy.Result(input, notation, input_format, resolver, representation, value)

A single result returned by CIR.

Parameters:
  • input (string) – Originally supplied input identifier that produced this result
  • notation (string) – Identifier matched by the resolver or tautomer ID
  • input_format (string) – Format of the input as interpreted by the resolver
  • resolver (string) – Resolver used to produce this result
  • representation (string) – Requested output representation
  • value (string or list(string)) – Actual result value
to_dict()

Return a dictionary containing Result data.

Images

cirpy.resolve_image(input, resolvers=None, fmt=u'png', width=300, height=300, frame=False, crop=None, bgcolor=None, atomcolor=None, hcolor=None, bondcolor=None, framecolor=None, symbolfontsize=11, linewidth=2, hsymbol=u'special', csymbol=u'special', stereolabels=False, stereowedges=True, header=None, footer=None, **kwargs)

Resolve input to a 2D image depiction.

Parameters:
  • input (string) – Chemical identifier to resolve
  • resolvers (list(string)) – (Optional) Ordered list of resolvers to use
  • fmt (string) – (Optional) gif or png image format (default png)
  • width (int) – (Optional) Image width in pixels (default 300)
  • height (int) – (Optional) Image height in pixels (default 300)
  • frame (bool) – (Optional) Whether to show border frame (default False)
  • crop (int) – (Optional) Crop image with specified padding
  • symbolfontsize (int) – (Optional) Atom label font size (default 11)
  • linewidth (int) – (Optional) Bond line width (default 2)
  • bgcolor (string) – (Optional) Background color
  • atomcolor (string) – (Optional) Atom label color
  • hcolor (string) – (Optional) Hydrogen atom label color
  • bondcolor (string) – (Optional) Bond color
  • framecolor (string) – (Optional) Border frame color
  • hsymbol (bool) – (Optional) Hydrogens: all, special or none (default special)
  • csymbol (bool) – (Optional) Carbons: all, special or none (default special)
  • stereolabels (bool) – (Optional) Whether to show stereochemistry labels (default False)
  • stereowedges (bool) – (Optional) Whether to show wedge/dash bonds (default True)
  • header (string) – (Optional) Header text above structure
  • footer (string) – (Optional) Footer text below structure

Request

cirpy.request(input, representation, resolvers=None, get3d=False, tautomers=False, **kwargs)

Make a request to CIR and return the XML response.

Parameters:
  • input (string) – Chemical identifier to resolve
  • representation (string) – Desired output representation
  • resolvers (list(string)) – (Optional) Ordered list of resolvers to use
  • get3d (bool) – (Optional) Whether to return 3D coordinates (where applicable)
  • tautomers (bool) – (Optional) Whether to return all tautomers
Returns:

XML response from CIR

Return type:

Element

Raises:
  • HTTPError – if CIR returns an error code
  • ParseError – if CIR response is uninterpretable

Download

cirpy.download(input, filename, representation, overwrite=False, resolvers=None, get3d=False, **kwargs)

Convenience function to save a CIR response as a file.

This is just a simple wrapper around the resolve function.

Parameters:
  • input (string) – Chemical identifier to resolve
  • filename (string) – File path to save to
  • representation (string) – Desired output representation
  • overwrite (bool) – (Optional) Whether to allow overwriting of an existing file
  • resolvers (list(string)) – (Optional) Ordered list of resolvers to use
  • get3d (bool) – (Optional) Whether to return 3D coordinates (where applicable)
Raises:
  • HTTPError – if CIR returns an error code
  • ParseError – if CIR response is uninterpretable
  • IOError – if overwrite is False and file already exists

API URLs

cirpy.construct_api_url(input, representation, resolvers=None, get3d=False, tautomers=False, xml=True, **kwargs)

Return the URL for the desired API endpoint.

Parameters:
  • input (string) – Chemical identifier to resolve
  • representation (string) – Desired output representation
  • resolvers (list(str)) – (Optional) Ordered list of resolvers to use
  • get3d (bool) – (Optional) Whether to return 3D coordinates (where applicable)
  • tautomers (bool) – (Optional) Whether to return all tautomers
  • xml (bool) – (Optional) Whether to return full XML response
Returns:

CIR API URL

Return type:

str

Molecule

class cirpy.Molecule(input, resolvers=None, get3d=False, **kwargs)

Class to hold and cache the structure information for a given CIR input.

Initialize with a resolver input.

stdinchi

Standard InChI.

stdinchikey

Standard InChIKey.

inchi

Non-standard InChI. (Uses options DONOTADDH W0 FIXEDH RECMET NEWPS SPXYZ SAsXYZ Fb Fnud).

smiles

SMILES string.

ficts

FICTS NCI/CADD hashed structure identifier.

ficus

FICuS NCI/CADD hashed structure identifier.

uuuuu

uuuuu NCI/CADD hashed structure identifier.

hashisy

CACTVS HASHISY identifier.

sdf

SDF file.

names

List of chemical names.

iupac_name

IUPAC approved name.

cas

CAS registry numbers.

mw

Molecular weight.

formula

Molecular formula

h_bond_donor_count

Hydrogen bond donor count.

h_bond_acceptor_count

Hydrogen bond acceptor count.

h_bond_center_count

Hydrogen bond center count.

rule_of_5_violation_count

Rule of 5 violation count.

rotor_count

Rotor count.

effective_rotor_count

Effective rotor count.

ring_count

Ring count.

ringsys_count

Ring system count.

image

2D image depiction.

image_url

URL of a GIF image.

twirl_url

Url of a TwirlyMol 3D viewer.

download(filename, representation, overwrite=False)

Download the resolved structure as a file.

Parameters:
  • filename (string) – File path to save to
  • representation (string) – Desired output representation
  • overwrite (bool) – (Optional) Whether to allow overwriting of an existing file