Welcome to ODDT’s documentation!

Installation

Requirements

  • Python 2.7.x
  • OpenBabel (2.3.2+) or/and RDKit (2014.03)
  • Numpy (1.8+)
  • Scipy (0.13+)
  • Sklearn (0.13+)
  • ffnet (0.7.1+) only for neural network functionality.
  • joblib (0.8+)

Note

All installation methods assume that one of toolkits is installed. For detailed installation procedure visit toolkit’s website (OpenBabel, RDKit)

Most convenient way of installing ODDT is using PIP. All required python modules will be installed automatically, although toolkits, either OpenBabel (pip install openbabel) or RDKit need to be installed manually

pip install oddt

If you want to install cutting edge version (master branch from GitHub) of ODDT also using PIP

pip install git+https://github.com/oddt/oddt.git@master

Finally you can install ODDT straight from the source

wget https://github.com/oddt/oddt/archive/0.1.1.tar.gz
tar zxvf 0.1.1.tar.gz
cd oddt-0.1.1/
python setup.py install

Common installation problems

ffnet requires numpy.distutils during installation, and you are trying to install ffnet without numpy. You have to install numpy first.

pip install numpy

Then you can install ODDT

pip install oddt

Usage Instructions

You can use any supported toolkit united under common API (for reference see Pybel or Cinfony). All methods and software which based on Pybel/Cinfony should be drop in compatible with ODDT toolkits. In contrast to it’s predecessors, which were aimed to have minimalistic API, ODDT introduces extended methods and additional handles. This extensions allow to use toolkits at all it’s grace and some features may be backported from others to introduce missing functionalities. To name a few:

  • coordinates are returned as Numpy Arrays
  • atoms and residues methods of Molecule class are lazy, ie. not returning a list of pointers, rather an object which allows indexing and iterating through atoms/residues
  • Bond object (similar to Atom)
  • atom_dict, ring_dict, res_dict - comprehensive Numpy Arrays containing common information about given entity, particularly useful for high performance computing, ie. interactions, scoring etc.
  • lazy Molecule (asynchronous), which is not converted to an object in reading phase, rather passed as a string and read in when underlying object is called
  • pickling introduced for Pybel Molecule (internally saved to mol2 string)

Atom, residues, bonds iteration

One of the most common operation would be iterating through molecules atoms

mol = oddt.toolkit.readstring(‘smi’, ‘c1cccc1’)
for atom in mol:
    print atom.idx

Note

mol.atoms, returns an object (AtomStack) which can be access via indexes or iterated

Iterating over residues is also very convenient, especially for proteins

for res in mol.residues:
    print res.name

Additionally residues can fetch atoms belonging to them:

for res in mol.residues:
    for atom in res:
        print atom.idx

Bonds are also iterable, similar to residues:

for bond in mol.bonds:
    print bond.order
    for atom in bond:
        print atom.idx

Reading molecules

Reading molecules is mostly identical to Pybel.

Reading from file

for mol in oddt.toolkit.readfile(‘smi’, ‘test.smi’):
    print mol.title

Reading from string

mol = oddt.toolkit.readstring(‘smi’, ‘c1ccccc1 benzene’):
    print mol.title

Note

You can force molecules to be read in asynchronously, aka “lazy molecules”. Current default is not to produce lazy molecules due to OpenBabel’s Memory Leaks in OBConverter. Main advantage of lazy molecules is using them in multiprocessing, then conversion is spreaded on all jobs.

Reading molecules from file in asynchronous manner

for mol in oddt.toolkit.readfile(‘smi’, ‘test.smi’, lazy=True):
    pass

This example will execute instantaneously, since no molecules were evaluated.

Numpy Dictionaries - store your molecule as an uniform structure

Most important and handy property of Molecule in ODDT are Numpy dictionaries containing most properties of supplied molecule. Some of them are straightforward, other require some calculation, ie. atom features. Dictionaries are provided for major entities of molecule: atoms, bonds, residues and rings. It was primarily used for interactions calculations, although it is applicable for any other calculation. The main benefit is marvelous Numpy broadcasting and subsetting.

Each dictionary is defined as a format in Numpy.

atom_dict

Atom basic information

  • coords‘, type: float16, shape: (3) - atom coordinates
  • charge‘, type: float16 - atom’s charge
  • atomicnum‘, type: int8 - atomic number
  • *atomtype’, type: a4 - Sybyl atom’s type
  • hybridization‘, type: int8 - atoms hybrydization
  • neighbors‘, type: float16, shape: (4,3) - coordinates of non-H neighbors coordinates for angles (max of 4 neighbors should be enough)

Residue information for current atom

  • resid‘, type: int16 - residue ID
  • resname‘, type: a3 - Residue name (3 letters)
  • isbackbone‘, type: bool - is atom part of backbone

Atom properties

  • isacceptor‘, type: bool - is atom H-bond acceptor
  • isdonor‘, type: bool - is atom H-bond donor
  • isdonorh‘, type: bool - is atom H-bond donor Hydrogen
  • ismetal‘, type: bool - is atom a metal
  • ishydrophobe‘, type: bool - is atom hydrophobic
  • isaromatic‘, type: bool - is atom aromatic
  • isminus‘, type: bool - is atom negatively charged/chargable
  • isplus‘, type: bool - is atom positively charged/chargable
  • ishalogen‘, type: bool - is atom a halogen

Secondary structure

  • isalpha‘, type: bool - is atom a part of alpha helix
  • isbeta‘, type: bool' - is atom a part of beta strand

ring_dict

  • centroid‘, type: float16, shape: 3 - coordinates of ring’s centroid
  • vector‘, type: float16, shape: 3 - normal vector for ring
  • isalpha‘, type: bool - is ring a part of alpha helix
  • isbeta‘, type: bool' - is ring a part of beta strand

res_dict

  • id‘, type: int16 - residue ID
  • resname‘, type: a3 - Residue name (3 letters)
  • N‘, type: float16, shape: 3 - cordinates of backbone N atom
  • CA‘, type: float16, shape: 3 - cordinates of backbone CA atom
  • C‘, type: float16, shape: 3 - cordinates of backbone C atom
  • isalpha‘, type: bool - is residue a part of alpha helix
  • isbeta‘, type: bool' - is residue a part of beta strand

Note

All aforementioned dictionaries are generated “on demand”, and are cached for molecule, thus can be shared between calculations. Caching of dictionaries brings incredible performance gain, since in some applications their generation is the major time consuming task.

Get all acceptor atoms:

mol.atom_dict[‘is_acceptor’]

ODDT API documentation

oddt package

Subpackages

oddt.docking package
Submodules
oddt.docking.AutodockVina module
Module contents
oddt.scoring package
Subpackages
oddt.scoring.descriptors package
Submodules
oddt.scoring.descriptors.binana module
Module contents
oddt.scoring.functions package
Submodules
oddt.scoring.functions.NNScore module
oddt.scoring.functions.RFScore module
Module contents
oddt.scoring.models package
Submodules
oddt.scoring.models.classifiers module
oddt.scoring.models.neuralnetwork module
oddt.scoring.models.regressors module
Module contents
Module contents
oddt.toolkits package
Submodules
oddt.toolkits.ob module
class oddt.toolkits.ob.AtomStack(OBMol)[source]

Bases: object

class oddt.toolkits.ob.Bond(OBBond)[source]

Bases: object

Attributes

atoms
isrotor
order
atoms
isrotor
order
class oddt.toolkits.ob.BondStack(OBMol)[source]

Bases: object

class oddt.toolkits.ob.Residue(OBResidue)[source]

Bases: object

Represent a Pybel residue.

Required parameter:
OBResidue – an Open Babel OBResidue
Attributes:
atoms, idx, name.

(refer to the Open Babel library documentation for more info).

The original Open Babel atom can be accessed using the attribute:
OBResidue

Attributes

atoms
idx
name
atoms
idx
name
oddt.toolkits.ob.pickle_mol(self)[source]
oddt.toolkits.ob.readfile(format, filename, opt=None, lazy=False)[source]
oddt.toolkits.ob.unpickle_mol(source)[source]
oddt.toolkits.rdk module

rdkit - A Cinfony module for accessing the RDKit from CPython

Global variables:
Chem and AllChem - the underlying RDKit Python bindings informats - a dictionary of supported input formats outformats - a dictionary of supported output formats descs - a list of supported descriptors fps - a list of supported fingerprint types forcefields - a list of supported forcefields
class oddt.toolkits.rdk.Atom(Atom)[source]

Bases: object

Represent an rdkit Atom.

Required parameters:
Atom – an RDKit Atom
Attributes:
atomicnum, coords, formalcharge
The original RDKit Atom can be accessed using the attribute:
Atom

Attributes

atomicnum
coords
formalcharge
idx Note that this index is 1-based and RDKit’s internal index in 0-based.
neighbors
partialcharge
atomicnum
coords
formalcharge
idx

Note that this index is 1-based and RDKit’s internal index in 0-based. Changed to be compatible with OpenBabel

neighbors
partialcharge
class oddt.toolkits.rdk.AtomStack(Mol)[source]

Bases: object

class oddt.toolkits.rdk.Fingerprint(fingerprint)[source]

Bases: object

A Molecular Fingerprint.

Required parameters:
fingerprint – a vector calculated by one of the fingerprint methods
Attributes:
fp – the underlying fingerprint object bits – a list of bits set in the Fingerprint
Methods:

The “|” operator can be used to calculate the Tanimoto coeff. For example, given two Fingerprints ‘a’, and ‘b’, the Tanimoto coefficient is given by:

tanimoto = a | b

Attributes

raw
raw
class oddt.toolkits.rdk.Molecule(Mol=None, source=None, protein=False)[source]

Bases: object

Represent an rdkit Molecule.

Required parameter:
Mol – an RDKit Mol or any type of cinfony Molecule
Attributes:
atoms, data, formula, molwt, title
Methods:
addh(), calcfp(), calcdesc(), draw(), localopt(), make3D(), removeh(), write()
The underlying RDKit Mol can be accessed using the attribute:
Mol

Attributes

Mol
atom_dict
atoms
canonic_order Returns np.array with canonic order of heavy atoms in the molecule
charges
clone
coords
data
formula
molwt
num_rotors
res_dict
ring_dict
sssr
title

Methods

addh() Add hydrogens.
calcdesc([descnames]) Calculate descriptor values.
calcfp([fptype, opt]) Calculate a molecular fingerprint.
clone_coords(source)
draw([show, filename, update, usecoords]) Create a 2D depiction of the molecule.
localopt([forcefield, steps]) Locally optimize the coordinates.
make3D([forcefield, steps]) Generate 3D coordinates.
removeh() Remove hydrogens.
write([format, filename, overwrite]) Write the molecule to a file or return a string.
Mol
addh()[source]

Add hydrogens.

atom_dict
atoms
calcdesc(descnames=[])[source]

Calculate descriptor values.

Optional parameter:
descnames – a list of names of descriptors

If descnames is not specified, all available descriptors are calculated. See the descs variable for a list of available descriptors.

calcfp(fptype='rdkit', opt=None)[source]

Calculate a molecular fingerprint.

Optional parameters:
fptype – the fingerprint type (default is “rdkit”). See the
fps variable for a list of of available fingerprint types.
opt – a dictionary of options for fingerprints. Currently only used
for radius and bitInfo in Morgan fingerprints.
canonic_order

Returns np.array with canonic order of heavy atoms in the molecule

charges
clone
clone_coords(source)[source]
coords
data
draw(show=True, filename=None, update=False, usecoords=False)[source]

Create a 2D depiction of the molecule.

Optional parameters:

show – display on screen (default is True) filename – write to file (default is None) update – update the coordinates of the atoms to those

determined by the structure diagram generator (default is False)
usecoords – don’t calculate 2D coordinates, just use
the current coordinates (default is False)

Aggdraw or Cairo is used for 2D depiction. Tkinter and Python Imaging Library are required for image display.

formula
localopt(forcefield='uff', steps=500)[source]

Locally optimize the coordinates.

Optional parameters:
forcefield – default is “uff”. See the forcefields variable
for a list of available forcefields.

steps – default is 500

If the molecule does not have any coordinates, make3D() is called before the optimization.

make3D(forcefield='uff', steps=50)[source]

Generate 3D coordinates.

Optional parameters:
forcefield – default is “uff”. See the forcefields variable
for a list of available forcefields.

steps – default is 50

Once coordinates are generated, a quick local optimization is carried out with 50 steps and the UFF forcefield. Call localopt() if you want to improve the coordinates further.

molwt
num_rotors
removeh()[source]

Remove hydrogens.

res_dict
ring_dict
sssr
title
write(format='smi', filename=None, overwrite=False, **kwargs)[source]

Write the molecule to a file or return a string.

Optional parameters:
format – see the informats variable for a list of available
output formats (default is “smi”)

filename – default is None overwite – if the output file already exists, should it

be overwritten? (default is False)

If a filename is specified, the result is written to a file. Otherwise, a string is returned containing the result.

To write multiple molecules to the same file you should use the Outputfile class.

class oddt.toolkits.rdk.MoleculeData(Mol)[source]

Bases: object

Store molecule data in a dictionary-type object

Required parameters:
Mol – an RDKit Mol

Methods and accessor methods are like those of a dictionary except that the data is retrieved on-the-fly from the underlying Mol.

Example: >>> mol = readfile(“sdf”, ‘head.sdf’).next() >>> data = mol.data >>> print data {‘Comment’: ‘CORINA 2.61 0041 25.10.2001’, ‘NSC’: ‘1’} >>> print len(data), data.keys(), data.has_key(“NSC”) 2 [‘Comment’, ‘NSC’] True >>> print data[‘Comment’] CORINA 2.61 0041 25.10.2001 >>> data[‘Comment’] = ‘This is a new comment’ >>> for k,v in data.iteritems(): ... print k, “–>”, v Comment –> This is a new comment NSC –> 1 >>> del data[‘NSC’] >>> print len(data), data.keys(), data.has_key(“NSC”) 1 [‘Comment’] False

Methods

clear()
has_key(key)
items()
iteritems()
keys()
update(dictionary)
values()
clear()[source]
has_key(key)[source]
items()[source]
iteritems()[source]
keys()[source]
update(dictionary)[source]
values()[source]
class oddt.toolkits.rdk.Outputfile(format, filename, overwrite=False)[source]

Bases: object

Represent a file to which output is to be sent.

Required parameters:
format - see the outformats variable for a list of available
output formats

filename

Optional parameters:
overwite – if the output file already exists, should it
be overwritten? (default is False)
Methods:
write(molecule) close()

Methods

close() Close the Outputfile to further writing.
write(molecule) Write a molecule to the output file.
close()[source]

Close the Outputfile to further writing.

write(molecule)[source]

Write a molecule to the output file.

Required parameters:
molecule
class oddt.toolkits.rdk.Smarts(smartspattern)[source]

Bases: object

Initialise with a SMARTS pattern.

Methods

findall(molecule) Find all matches of the SMARTS pattern to a particular molecule.
findall(molecule)[source]

Find all matches of the SMARTS pattern to a particular molecule.

Required parameters:
molecule
oddt.toolkits.rdk.base_feature_factory = <MagicMock name='mock.Chem.AllChem.BuildFeatureFactory()' id='139808668853456'>

Global feature factory based on BaseFeatures.fdef

oddt.toolkits.rdk.descs = []

A list of supported descriptors

oddt.toolkits.rdk.forcefields = ['uff']

A list of supported forcefields

oddt.toolkits.rdk.fps = ['rdkit', 'layered', 'maccs', 'atompairs', 'torsions', 'morgan']

A list of supported fingerprint types

oddt.toolkits.rdk.informats = {'inchi': 'InChI', 'mol2': 'Tripos MOL2 file', 'sdf': 'MDL SDF file', 'smi': 'SMILES', 'mol': 'MDL MOL file'}

A dictionary of supported input formats

oddt.toolkits.rdk.outformats = {'inchikey': 'InChIKey', 'sdf': 'MDL SDF file', 'can': 'Canonical SMILES', 'smi': 'SMILES', 'mol': 'MDL MOL file', 'inchi': 'InChI'}

A dictionary of supported output formats

oddt.toolkits.rdk.readfile(format, filename, *args, **kwargs)[source]

Iterate over the molecules in a file.

Required parameters:
format - see the informats variable for a list of available
input formats

filename

You can access the first molecule in a file using the next() method of the iterator:

mol = readfile(“smi”, “myfile.smi”).next()
You can make a list of the molecules in a file using:
mols = list(readfile(“smi”, “myfile.smi”))

You can iterate over the molecules in a file as shown in the following code snippet: >>> atomtotal = 0 >>> for mol in readfile(“sdf”, “head.sdf”): ... atomtotal += len(mol.atoms) ... >>> print atomtotal 43

oddt.toolkits.rdk.readstring(format, string, **kwargs)[source]

Read in a molecule from a string.

Required parameters:
format - see the informats variable for a list of available
input formats

string

Example: >>> input = “C1=CC=CS1” >>> mymol = readstring(“smi”, input) >>> len(mymol.atoms) 5

Module contents

Submodules

oddt.datasets module

oddt.interactions module

Module calculates interactions between two molecules (proein-protein, protein-ligand, small-small). Currently following interacions are implemented:

  • hydrogen bonds
  • halogen bonds
  • pi stacking (parallel and perpendicular)
  • salt bridges
  • hydrophobic contacts
  • pi-cation
  • metal coordination
  • pi-metal
oddt.interactions.close_contacts(x, y, cutoff, x_column='coords', y_column='coords')[source]

Returns pairs of atoms which are within close contac distance cutoff.

Parameters:

x, y : atom_dict-type numpy array

Atom dictionaries generated by oddt.toolkit.Molecule objects.

cutoff : float

Cutoff distance for close contacts

x_column, ycolumn : string, (default=’coords’)

Column containing coordinates of atoms (or pseudo-atoms, i.e. ring centroids)

Returns:

x_, y_ : atom_dict-type numpy array

Aligned pairs of atoms in close contact for further processing.

oddt.interactions.hbond_acceptor_donor(mol1, mol2, cutoff=3.5, base_angle=120, tolerance=30)[source]

Returns pairs of acceptor-donor atoms, which meet H-bond criteria

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute H-bond acceptor and H-bond donor pairs

cutoff : float, (default=3.5)

Distance cutoff for A-D pairs

base_angle : int, (default=120)

Base angle determining allowed direction of hydrogen bond formation, which is devided by the number of neighbors of acceptor atom to establish final directional angle

tolerance : int, (default=30)

Range (+/- tolerance) from perfect direction (base_angle/n_neighbors) in which H-bonds are considered as strict.

Returns:

a, d : atom_dict-type numpy array

Aligned arrays of atoms forming H-bond, firstly acceptors, secondly donors.

strict : numpy array, dtype=bool

Boolean array align with atom pairs, informing whether atoms form ‘strict’ H-bond (pass all angular cutoffs). If false, only distance cutoff is met, therefore the bond is ‘crude’.

oddt.interactions.hbond(mol1, mol2, *args, **kwargs)[source]

Calculates H-bonds between molecules

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute H-bond acceptor and H-bond donor pairs

cutoff : float, (default=3.5)

Distance cutoff for A-D pairs

base_angle : int, (default=120)

Base angle determining allowed direction of hydrogen bond formation, which is devided by the number of neighbors of acceptor atom to establish final directional angle

tolerance : int, (default=30)

Range (+/- tolerance) from perfect direction (base_angle/n_neighbors) in which H-bonds are considered as strict.

Returns:

mol1_atoms, mol2_atoms : atom_dict-type numpy array

Aligned arrays of atoms forming H-bond

strict : numpy array, dtype=bool

Boolean array align with atom pairs, informing whether atoms form ‘strict’ H-bond (pass all angular cutoffs). If false, only distance cutoff is met, therefore the bond is ‘crude’.

oddt.interactions.halogenbond_acceptor_halogen(mol1, mol2, base_angle_acceptor=120, base_angle_halogen=180, tolerance=30, cutoff=4)[source]

Returns pairs of acceptor-halogen atoms, which meet halogen bond criteria

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute halogen bond acceptor and halogen pairs

cutoff : float, (default=4)

Distance cutoff for A-H pairs

base_angle_acceptor : int, (default=120)

Base angle determining allowed direction of halogen bond formation, which is devided by the number of neighbors of acceptor atom to establish final directional angle

base_angle_halogen : int (default=180)

Ideal base angle between halogen bond and halogen-neighbor bond

tolerance : int, (default=30)

Range (+/- tolerance) from perfect direction (base_angle/n_neighbors) in which halogen bonds are considered as strict.

Returns:

a, h : atom_dict-type numpy array

Aligned arrays of atoms forming halogen bond, firstly acceptors, secondly halogens

strict : numpy array, dtype=bool

Boolean array align with atom pairs, informing whether atoms form ‘strict’ halogen bond (pass all angular cutoffs). If false, only distance cutoff is met, therefore the bond is ‘crude’.

oddt.interactions.halogenbond(mol1, mol2, **kwargs)[source]

Calculates halogen bonds between molecules

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute halogen bond acceptor and halogen pairs

cutoff : float, (default=4)

Distance cutoff for A-H pairs

base_angle_acceptor : int, (default=120)

Base angle determining allowed direction of halogen bond formation, which is devided by the number of neighbors of acceptor atom to establish final directional angle

base_angle_halogen : int (default=180)

Ideal base angle between halogen bond and halogen-neighbor bond

tolerance : int, (default=30)

Range (+/- tolerance) from perfect direction (base_angle/n_neighbors) in which halogen bonds are considered as strict.

Returns:

mol1_atoms, mol2_atoms : atom_dict-type numpy array

Aligned arrays of atoms forming halogen bond

strict : numpy array, dtype=bool

Boolean array align with atom pairs, informing whether atoms form ‘strict’ halogen bond (pass all angular cutoffs). If false, only distance cutoff is met, therefore the bond is ‘crude’.

oddt.interactions.pi_stacking(mol1, mol2, cutoff=5, tolerance=30)[source]

Returns pairs of rings, which meet pi stacking criteria

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute ring pairs

cutoff : float, (default=5)

Distance cutoff for Pi-stacking pairs

tolerance : int, (default=30)

Range (+/- tolerance) from perfect direction (parallel or perpendicular) in which pi-stackings are considered as strict.

Returns:

r1, r2 : ring_dict-type numpy array

Aligned arrays of rings forming pi-stacking

strict_parallel : numpy array, dtype=bool

Boolean array align with ring pairs, informing whether rings form ‘strict’ parallel pi-stacking. If false, only distance cutoff is met, therefore the stacking is ‘crude’.

strict_perpendicular : numpy array, dtype=bool

Boolean array align with ring pairs, informing whether rings form ‘strict’ perpendicular pi-stacking (T-shaped, T-face, etc.). If false, only distance cutoff is met, therefore the stacking is ‘crude’.

oddt.interactions.salt_bridge_plus_minus(mol1, mol2, cutoff=4)[source]

Returns pairs of plus-mins atoms, which meet salt bridge criteria

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute plus and minus pairs

cutoff : float, (default=4)

Distance cutoff for A-H pairs

Returns:

plus, minus : atom_dict-type numpy array

Aligned arrays of atoms forming salt bridge, firstly plus, secondly minus

oddt.interactions.salt_bridges(mol1, mol2, *args, **kwargs)[source]

Calculates salt bridges between molecules

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute plus and minus pairs

cutoff : float, (default=4)

Distance cutoff for plus-minus pairs

Returns:

mol1_atoms, mol2_atoms : atom_dict-type numpy array

Aligned arrays of atoms forming salt bridges

oddt.interactions.hydrophobic_contacts(mol1, mol2, cutoff=4)[source]

Calculates hydrophobic contacts between molecules

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute hydrophobe pairs

cutoff : float, (default=4)

Distance cutoff for hydrophobe pairs

Returns:

mol1_atoms, mol2_atoms : atom_dict-type numpy array

Aligned arrays of atoms forming hydrophobic contacts

oddt.interactions.pi_cation(mol1, mol2, cutoff=5, tolerance=30)[source]

Returns pairs of ring-cation atoms, which meet pi-cation criteria

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute ring-cation pairs

cutoff : float, (default=5)

Distance cutoff for Pi-cation pairs

tolerance : int, (default=30)

Range (+/- tolerance) from perfect direction (perpendicular) in which pi-cation are considered as strict.

Returns:

r1 : ring_dict-type numpy array

Aligned rings forming pi-stacking

plus2 : atom_dict-type numpy array

Aligned cations forming pi-cation

strict_parallel : numpy array, dtype=bool

Boolean array align with ring-cation pairs, informing whether they form ‘strict’ pi-cation. If false, only distance cutoff is met, therefore the interaction is ‘crude’.

oddt.interactions.acceptor_metal(mol1, mol2, base_angle=120, tolerance=30, cutoff=4)[source]

Returns pairs of acceptor-metal atoms, which meet metal coordination criteria Note: This function is directional (mol1 holds acceptors, mol2 holds metals)

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute acceptor and metal pairs

cutoff : float, (default=4)

Distance cutoff for A-M pairs

base_angle : int, (default=120)

Base angle determining allowed direction of metal coordination, which is devided by the number of neighbors of acceptor atom to establish final directional angle

tolerance : int, (default=30)

Range (+/- tolerance) from perfect direction (base_angle/n_neighbors) in metal coordination are considered as strict.

Returns:

a, d : atom_dict-type numpy array

Aligned arrays of atoms forming metal coordination, firstly acceptors, secondly metals.

strict : numpy array, dtype=bool

Boolean array align with atom pairs, informing whether atoms form ‘strict’ metal coordination (pass all angular cutoffs). If false, only distance cutoff is met, therefore the interaction is ‘crude’.

oddt.interactions.pi_metal(mol1, mol2, cutoff=5, tolerance=30)[source]

Returns pairs of ring-metal atoms, which meet pi-metal criteria

Parameters:

mol1, mol2 : oddt.toolkit.Molecule object

Molecules to compute ring-metal pairs

cutoff : float, (default=5)

Distance cutoff for Pi-metal pairs

tolerance : int, (default=30)

Range (+/- tolerance) from perfect direction (perpendicular) in which pi-metal are considered as strict.

Returns:

r1 : ring_dict-type numpy array

Aligned rings forming pi-metal

m : atom_dict-type numpy array

Aligned metals forming pi-metal

strict_parallel : numpy array, dtype=bool

Boolean array align with ring-metal pairs, informing whether they form ‘strict’ pi-metal. If false, only distance cutoff is met, therefore the interaction is ‘crude’.

oddt.metrics module

oddt.spatial module

Spatial functions included in ODDT Mainly used by other modules, but can be accessed directly.

oddt.spatial.angle(p1, p2, p3)[source]

Returns an angle from a series of 3 points (point #2 is centroid).Angle is returned in degrees.

Parameters:

p1,p2,p3 : numpy arrays, shape = [n_points, n_dimensions]

Triplets of points in n-dimensional space, aligned in rows.

Returns:

angles : numpy array, shape = [n_points]

Series of angles in degrees

oddt.spatial.angle_2v(v1, v2)[source]

Returns an angle between two vecors.Angle is returned in degrees.

Parameters:

v1,v2 : numpy arrays, shape = [n_vectors, n_dimensions]

Pairs of vectors in n-dimensional space, aligned in rows.

Returns:

angles : numpy array, shape = [n_vectors]

Series of angles in degrees

oddt.spatial.dihedral(p1, p2, p3, p4)[source]

Returns an dihedral angle from a series of 4 points. Dihedral is returned in degrees. Function distingishes clockwise and antyclockwise dihedrals.

Parameters:

p1,p2,p3,p4 : numpy arrays, shape = [n_points, n_dimensions]

Quadruplets of points in n-dimensional space, aligned in rows.

Returns:

angles : numpy array, shape = [n_points]

Series of angles in degrees

oddt.spatial.distance(XA, XB, metric='euclidean', p=2, V=None, VI=None, w=None)

Computes distance between each pair of the two collections of inputs.

The following are common calling conventions:

  1. Y = cdist(XA, XB, 'euclidean')

    Computes the distance between \(m\) points using Euclidean distance (2-norm) as the distance metric between the points. The points are arranged as \(m\) \(n\)-dimensional row vectors in the matrix X.

  2. Y = cdist(XA, XB, 'minkowski', p)

    Computes the distances using the Minkowski distance \(||u-v||_p\) (\(p\)-norm) where \(p \geq 1\).

  3. Y = cdist(XA, XB, 'cityblock')

    Computes the city block or Manhattan distance between the points.

  4. Y = cdist(XA, XB, 'seuclidean', V=None)

    Computes the standardized Euclidean distance. The standardized Euclidean distance between two n-vectors u and v is

    \[\sqrt{\sum {(u_i-v_i)^2 / V[x_i]}}.\]

    V is the variance vector; V[i] is the variance computed over all the i’th components of the points. If not passed, it is automatically computed.

  5. Y = cdist(XA, XB, 'sqeuclidean')

    Computes the squared Euclidean distance \(||u-v||_2^2\) between the vectors.

  6. Y = cdist(XA, XB, 'cosine')

    Computes the cosine distance between vectors u and v,

    \[1 - \frac{u \cdot v} {{||u||}_2 {||v||}_2}\]

    where \(||*||_2\) is the 2-norm of its argument *, and \(u \cdot v\) is the dot product of \(u\) and \(v\).

  7. Y = cdist(XA, XB, 'correlation')

    Computes the correlation distance between vectors u and v. This is

    \[1 - \frac{(u - \bar{u}) \cdot (v - \bar{v})} {{||(u - \bar{u})||}_2 {||(v - \bar{v})||}_2}\]

    where \(\bar{v}\) is the mean of the elements of vector v, and \(x \cdot y\) is the dot product of \(x\) and \(y\).

  8. Y = cdist(XA, XB, 'hamming')

    Computes the normalized Hamming distance, or the proportion of those vector elements between two n-vectors u and v which disagree. To save memory, the matrix X can be of type boolean.

  9. Y = cdist(XA, XB, 'jaccard')

    Computes the Jaccard distance between the points. Given two vectors, u and v, the Jaccard distance is the proportion of those elements u[i] and v[i] that disagree where at least one of them is non-zero.

  10. Y = cdist(XA, XB, 'chebyshev')

Computes the Chebyshev distance between the points. The Chebyshev distance between two n-vectors u and v is the maximum norm-1 distance between their respective elements. More precisely, the distance is given by

\[d(u,v) = \max_i {|u_i-v_i|}.\]
  1. Y = cdist(XA, XB, 'canberra')

Computes the Canberra distance between the points. The Canberra distance between two points u and v is

\[d(u,v) = \sum_i \frac{|u_i-v_i|} {|u_i|+|v_i|}.\]
  1. Y = cdist(XA, XB, 'braycurtis')

Computes the Bray-Curtis distance between the points. The Bray-Curtis distance between two points u and v is

\[d(u,v) = \frac{\sum_i (u_i-v_i)} {\sum_i (u_i+v_i)}\]
  1. Y = cdist(XA, XB, 'mahalanobis', VI=None)
Computes the Mahalanobis distance between the points. The Mahalanobis distance between two points u and v is \((u-v)(1/V)(u-v)^T\) where \((1/V)\) (the VI variable) is the inverse covariance. If VI is not None, VI will be used as the inverse covariance matrix.
  1. Y = cdist(XA, XB, 'yule')
Computes the Yule distance between the boolean vectors. (see yule function documentation)
  1. Y = cdist(XA, XB, 'matching')
Computes the matching distance between the boolean vectors. (see matching function documentation)
  1. Y = cdist(XA, XB, 'dice')
Computes the Dice distance between the boolean vectors. (see dice function documentation)
  1. Y = cdist(XA, XB, 'kulsinski')
Computes the Kulsinski distance between the boolean vectors. (see kulsinski function documentation)
  1. Y = cdist(XA, XB, 'rogerstanimoto')
Computes the Rogers-Tanimoto distance between the boolean vectors. (see rogerstanimoto function documentation)
  1. Y = cdist(XA, XB, 'russellrao')
Computes the Russell-Rao distance between the boolean vectors. (see russellrao function documentation)
  1. Y = cdist(XA, XB, 'sokalmichener')
Computes the Sokal-Michener distance between the boolean vectors. (see sokalmichener function documentation)
  1. Y = cdist(XA, XB, 'sokalsneath')
Computes the Sokal-Sneath distance between the vectors. (see sokalsneath function documentation)
  1. Y = cdist(XA, XB, 'wminkowski')
Computes the weighted Minkowski distance between the vectors. (see sokalsneath function documentation)
  1. Y = cdist(XA, XB, f)

Computes the distance between all pairs of vectors in X using the user supplied 2-arity function f. For example, Euclidean distance between the vectors could be computed as follows:

dm = cdist(XA, XB, lambda u, v: np.sqrt(((u-v)**2).sum()))

Note that you should avoid passing a reference to one of the distance functions defined in this library. For example,:

dm = cdist(XA, XB, sokalsneath)

would calculate the pair-wise distances between the vectors in X using the Python function sokalsneath. This would result in sokalsneath being called \({n \choose 2}\) times, which is inefficient. Instead, the optimized C version is more efficient, and we call it using the following syntax.:

dm = cdist(XA, XB, 'sokalsneath')
Parameters:

XA : ndarray

An \(m_A\) by \(n\) array of \(m_A\) original observations in an \(n\)-dimensional space.

XB : ndarray

An \(m_B\) by \(n\) array of \(m_B\) original observations in an \(n\)-dimensional space.

metric : string or function

The distance metric to use. The distance function can be ‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘cityblock’, ‘correlation’, ‘cosine’, ‘dice’, ‘euclidean’, ‘hamming’, ‘jaccard’, ‘kulsinski’, ‘mahalanobis’, ‘matching’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, ‘seuclidean’, ‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, ‘wminkowski’, ‘yule’.

w : ndarray

The weight vector (for weighted Minkowski).

p : double

The p-norm to apply (for Minkowski, weighted and unweighted)

V : ndarray

The variance vector (for standardized Euclidean).

VI : ndarray

The inverse of the covariance matrix (for Mahalanobis).

Returns:

Y : ndarray

A \(m_A\) by \(m_B\) distance matrix is returned. For each \(i\) and \(j\), the metric dist(u=XA[i], v=XB[j]) is computed and stored in the \(ij\) th entry.

Raises:

An exception is thrown if ``XA`` and ``XB`` do not have

the same number of columns.

oddt.virtualscreening module

Module contents

Open Drug Discovery Toolkit

Universal and easy to use resource for various drug discovery tasks, ie docking, virutal screening, rescoring.

toolkit : module,
Toolkits backend module, currenlty OpenBabel [ob] and RDKit [rdk]. This setting is toolkit-wide, and sets given toolkit as default

References

To be announced.