This is a small introduction to help you get started with Chemaxon Python API. For a thorough documentation, go to the API Reference. A more detailed list of examples can be found in the python examples project.
You can easily import molecules from various formats. You can either specify the format yourself, or if you do not specify any format, the function will recognize the format automatically.
from chemaxon import import_mol
mol = import_mol("CC(=O)OC1=CC=CC=C1C(O)=O")
mol2 = import_mol("CC(=O)OC1=CC=CC=C1C(O)=O", "smiles")
The import_mol
function returns a chemaxon.molecule.Molecule
object on success.
Once you have a molecule, you can calculate various properties of it.
from chemaxon import logp, LogpMethod
result = logp(mol, method=LogpMethod.CHEMAXON, consider_tautomerization=True)
This function returns a chemaxon.calculations.logp.LogPResult
object, which contains the calculated logP value,
and the logP values of the individual atoms.
You can also calculate logp using the default parameter values:
from chemaxon import logp
result = logp(mol)
Chemaxon has a number of functions that you can use to generate fingerprints.
from chemaxon import cfp, ecfp
cfp = cfp(mol)
ecfp = ecfp(mol, 4, 1024)
These functions return chemaxon.fingerprints.fingerprint.Fingerprint
objects. You can get the fingerprints
in bytes or in binary string format.
ecfp.to_bytes()
ecfp.to_binary_string()
You can also calculate pharmacophore fingerprints:
from chemaxon import pharmacophore_fp
pf = pharmacophore_fp(mol)
This method returns a FloatVectorFingerprint
, which contains a float array.
You can also calculate Tanimoto Dissimilarity for the fingerprints:
from chemaxon import tanimoto, ecfp, pharmacophore_fp, float_vector_tanimoto
ecfp1 = ecfp(mol, 4, 1024)
ecfp2 = ecfp(mol2, 4, 1024)
result1 = tanimoto(ecfp1, ecfp2)
pf1 = pharmacophore_fp(mol)
pf2 = pharmacophore_fp(mol2)
result2 = float_vector_tanimoto(pf1, pf2)
The molecule can be exported to an svg file string:
from chemaxon import import_mol
mol = import_mol("CC(=O)OC1=CC=CC=C1C(O)=O")
svg = mol._repr_svg_()
from chemaxon import Molecule, LogpMethod, import_mol, logp
try:
# for illustrating exeption raising, a non-importable molecule is used
mol = Molecule("non-importable", None)
logp(mol, LogpMethod.CHEMAXON, -12, -34, consider_tautomerization=True, ph=15)
except RuntimeError as e:
# custom error handler code