Molecule API

Introduction

The ccdc.molecule contains classes concerned with chemistry.

The three main classes of the ccdc.molecule module are:

The ccdc.molecule.Molecule class contains attributes relating to the chemistry of the molecule, for example the SMILES representation.

>>> from ccdc.io import MoleculeReader
>>> csd_mol_reader = MoleculeReader('CSD')
>>> first_mol_in_csd = csd_mol_reader[0]
>>> print(first_mol_in_csd.smiles)
CC(=O)NN1C=NN=C1N(N=Cc1c(Cl)cccc1Cl)C(C)=O

In some cases a molecule may not have a canonical SMILES representation - where the structure has unknown atoms or bonds. In these cases the value will be None:

>>> AJABIX01 = csd_mol_reader.molecule('AJABIX01')
>>> print(AJABIX01.smiles)
None

The ccdc.molecule.Molecule also contains lists of atoms and bonds.

>>> len(first_mol_in_csd.atoms)
35
>>> len(first_mol_in_csd.bonds)
36
>>> first_atom = first_mol_in_csd.atoms[0]
>>> first_bond = first_mol_in_csd.bonds[0]

The ccdc.molecule.Atom contains attributes such as the ccdc.molecule.Atom.atomic_symbol.

>>> print(first_atom.atomic_symbol)
Cl

The ccdc.molecule.Bond contains attributes such as the ccdc.molecule.Bond.bond_type.

>>> first_bond.bond_type  
<ccdc.molecule.Bond.BondType object at ...>
>>> str(first_bond.bond_type)
'Single'
>>> first_bond.bond_type == 1
True

API

class ccdc.molecule.Atom(atomic_symbol='', atomic_number=0, coordinates=None, label='', formal_charge=0, _atom=None)[source]

Represents an atom.

class DisplacementParameters(_displacement_parameters)[source]

Represents the atomic displacement parameters of an atom, where present.

Atoms read from a PDB format file may have displacement parameters, the same is true for structures read from a CIF format, and structures from newer versions of the CSD SQLite crystal structure databases.

property isotropic_equivalent

The equivalent isotropic displacement.

See Fischer and Tillmanns (1988), Acta Cryst. C44, pp. 775-776.

property precision

The precision of uncertainty values in the displacement parameters.

property temperature_factor

The temperature factor.

property type

Whether the atomic displacement parameters are anisotropic, isotropic, from multipole expansion or None if no atomic displacement parameters are available.

Entries from the CSD will only have anisotropic, isotropic or None.

Returns:

One of ‘Anisotropic’, ‘Isotropic’, ‘Multipole’, or None if no atomic displacement

parameters are defined.

property uncertainties

The uncertainties in the displacement parameters.

property values

The six values of the displacement parameters.

property atomic_number

The atomic number of the element represented.

>>> atom = Atom(atomic_symbol='N')
>>> print(atom.atomic_number)
7
property atomic_symbol

The atomic symbol of the element represented.

>>> atom = Atom(atomic_symbol='N')
>>> print(atom.atomic_symbol)
N
property atomic_weight

The atomic weight of the atom.

property bonds

The bonds which this atom forms

property chain_label

The label of the chain in which the atom lies if available.

property chirality

The R/S Chirality flag for this atom.

Returns one of ‘’, ‘R’, ‘S’, ‘Mixed’, ‘Error’.

property coordinates

The x, y, z coordinates of the atoms in orthogonal space.

>>> atom = Atom(atomic_symbol='C', coordinates=(1.0, 2.0, 3.0))
>>> atom.coordinates
Coordinates(x=1.000, y=2.000, z=3.000)

The coordinates may be addressed by index or by key:

>>> atom.coordinates.x
1.0
>>> atom.coordinates[2]
3.0

Note that this function will return None if the atom does not have 3D coordinates.

>>> atom = Atom(atomic_symbol='C')
>>> print(atom.coordinates)
None
property displacement_parameters

The displacement parameters of this atom.

Returns:

ccdc.molecule.Atom.DisplacementParameters or None

property formal_charge

Formal charge on the atom.

>>> atom = Atom(atomic_symbol='Cl')
>>> atom.formal_charge
0
property fractional_coordinates

The fractional coordinates of an atom.

The coordinates of the atom expressed in terms of the underlying crystal’s unit cell. Where there is no underlying crystal, these will appear relative to the default unit cell, so orthogonal and fractional coordinates coincide.

property fractional_uncertainties

The fractional coordinates of the atom with the uncertainty information, if present.

If no uncertainty information was recorded for the atom, this will be None.

property index

The index of this atom in its parent molecule.

Note that if an atom is not part of a molecule this function will return None.

>>> atom = Atom(atomic_symbol='Fe')
>>> print(atom.index)
None
property is_acceptor

Test whether or not the atom is a hydrogen bond acceptor.

>>> atom = Atom(atomic_symbol='C')
>>> atom.is_acceptor
False
property is_chiral

Whether the atom is chiral.

>>> atom = Atom()
>>> atom.is_chiral
False

Returns True if the R/S Chirality flag for this atom is one of ‘R’, ‘S’, or ‘Mixed’.

property is_cyclic

Test whether the atom is part of a ring system.

>>> atom = Atom()
>>> atom.is_cyclic
False
property is_donor

Test whether or not the atom is a hydrogen bond donor.

>>> atom = Atom(atomic_symbol='C')
>>> atom.is_donor
False
is_in_line_of_sight(atom, molecules=None)[source]

Whether the other atom is within the line of this atom.

Parameters:
  • atom – a ccdc.molecule.Atom instance.

  • molecules – an iterable of molecules to test for occlusion, or None.

If molecules is None or an empty iterable the only molecules to be tested will be those of the atoms involved.

property is_in_protein

Whether or not the atom is in a protein.

property is_metal

Whether this atom is a metal.

>>> atom = Atom(atomic_symbol='C')
>>> atom.is_metal
False
>>> atom = Atom(atomic_symbol='Hg')
>>> atom.is_metal
True
property is_spiro

Whether this is a spiro atom.

property label

The label for the atom.

>>> atom = Atom(atomic_symbol='C', label='C1')
>>> print(atom.label)
C1
>>> atom = Atom(atomic_symbol='C')
>>> print(atom.label)
property neighbours

Those atoms bonded to this one

property occupancy

The occupancy of the atom.

property partial_charge

Partial charge on the atom.

property protein_atom_type

The protein atom type of an atom.

This may be ‘Amino_acid’, ‘Ligand’, ‘Cofactor’, ‘Water’, ‘Metal’, ‘Nucleotide’ or ‘Unknown’.

property residue_label

The residue label of the atom if available, or None.

property rings

The collection of ccdc.molecule.Ring in which this atom lies.

solvent_accessible_surface(probe_radius=1.1, npoints=6000, method='random', filter_by_ligand=False, ligand_atoms=None)[source]

The fraction of the atom’s surface which is solvent-accessible.

Parameters:
  • probe_radius – the radius of the probe’s sphere.

  • npoints – the number of points to generate on the surface of a sphere.

  • method – one of ‘random’ or ‘equidistant’

  • filter_by_ligand – bool True or False - this parameter controls whether

to measure the contacting accessible surface. If True then only the solvent accessible surface that is within a certain distance of the ligand atoms is counted. This allows the user to measure, on this molecule, the accessible surface that is in contact with another molecule. :parameter ligand_atoms: list of atoms :returns: the fraction of the atom’s surface area which is accessible.

property sybyl_type

The Sybyl atom type of an atom.

property vdw_radius

The Van der Waals radius of the atom.

class ccdc.molecule.Bond(bond_type=None, _bond=None)[source]

A bond between two atoms of a molecule.

class BondType(bond_type)[source]

Represent a bond type as either an integer or a string.

>>> bond_type = Bond.BondType(1)
>>> print(bond_type)
Single
>>> bond_type == 1
True
static all_bond_types()[source]

Return dictionary of all valid CSD bond types.

property atoms

The two atoms which this bond connects.

property bond_type

The bond type represented as a ccdc.molecule.Bond.BondType.

property ez_stereochemistry

The E/Z stereochemistry for this bond.

Returns one of ‘’, ‘E’, ‘Z’, ‘Unknown’, ‘Error’.

property ideal_bond_length

The ideal bond length for a bond of this type connected these atoms.

property is_conjugated

Whether the bond is conjugated.

property is_cyclic

Test whether the bond is part of a ring system.

property is_rotatable

Test whether the bond is rotatable.

property length

The length of the bond in Angstroms.

property rings

The collection of ccdc.molecule.Ring of which this bond is a part.

property sybyl_type

The Sybyl bond type of this bond.

class ccdc.molecule.Ring(atoms, _molecule=None)[source]

A ring of atoms in a molecule.

property bonds

The bonds of this ring.

property is_aromatic

Whether or not the ring is aromatic.

property is_fully_conjugated

Whether each bond of the ring is conjugated.

property is_fused

Whether the ring is fused with another.

class ccdc.molecule.Molecule(identifier='', _molecule=None)[source]

Represents a molecule

class Contact(_contact)[source]

A contact between two molecules.

property atoms

The atoms forming this contact.

property intermolecular

Whether the contact is inter- or intra-molecular.

property is_in_line_of_sight

Whether the contact is occluded by other atoms of the structure.

property length

The length of the contact.

property strength

The strength of this contact.

property type

The type of contact.

class HBond(_contact)[source]

A hydrogen bond between atoms of a molecule.

property angle

The donor-hydrogen-acceptor angle or None if the hydrogen is implicit.

property atoms

The atoms forming this contact.

If a Hydrogen is present in the contact it will be the central atom. Either the donor or the acceptor may come first: which may be determined by inspecting the neighbours of the atoms. (Testing the attribute ccdc.molecule.atom.is_donor can be misleading if an atom acts as both a donor and an acceptor in a crystal structure.)

property da_distance

The donor-acceptor distance of this hydrogen bond.

property is_in_line_of_sight

Whether the HBond is in line of sight or occluded.

property length

The length of the hydrogen bond.

This is the distance between the hydrogen and the acceptor, or None if the hydrogen is implicit.

property type

The type of this contact (‘HBond’).

class HBondCriterion(_hbc=None)[source]

Defines the conditions for an HBond to be detected in a molecule.

Contains two dictionary like objects for the donor atom types and the acceptor atom types, whether or not hydrogens are required, a distance range and an angle tolerance (if hydrogen atoms are required), whether or not the distance range is relative to Van der Waals radii, whether inter-, intra- or both HBonds should be detected, and a range of path separation distances for atoms to be considered hydrogen bonded.

In almost all cases the defaults will give good results, but users may wish to fine-tune the detection algorithm.

class HBondAtomTypes(type, _hbc)[source]

A dictionary-like class providing access to the atom types of a donor or an acceptor.

items()[source]

The atom type names and whether or not they will be considered for HBonding purposes.

keys()[source]

The atom type names.

acceptor_atom_type(atom)[source]

Return the string representation of the atom’s type.

property angle_tolerance

The tolerance of the HBond angle.

property distance_range

Allowable distance range for an HBond to be formed.

donor_atom_type(atom)[source]

Return the string representation of the atom’s type.

property intermolecular

Whether HBonds should be intermolecular, intramolecular, or any.

is_acceptor(atom)[source]

Whether the atom be considered an acceptor by this criterion.

is_donor(atom)[source]

Whether the atom be considered a donor by this HBondCriterion.

property path_length_range

The shortest and longest bond-path separation for intramolecular contacts.

property require_hydrogens

Whether Hydrogens are required for the HBond.

set_acceptor_type(atom, value)[source]

Set the acceptor properties of the type of the atom.

set_donor_type(atom, value)[source]

Set the donor properties of the type of the atom.

property vdw_corrected

Whether the distance range is Van der Waals corrected.

class Transformation(matrix=None, _transformation=None)[source]

Transformation matrix that could be applied to the coordinates of a molecule

static from_rotation_and_translation(rotation, translation)[source]

Create a transformation from a rotation matrix and translation vector

Parameters:
  • rotation – A 3 x 3 rotation matrix as a tuple of 3 tuples of 3 doubles

  • translation – A translation vector as a tuple of 3 doubles (x, y, z)

Returns:

A Molecule.Transformation

inverse()[source]

Return the inverse of this transformation

Returns:

A Molecule.Transformation that is the inverse of this transformation

property rotation

The rotational component of the transformation

Returns:

A 3 x 3 rotation matrix as a tuple of 3 tuples of 3 doubles

property translation

The translational component of the transformation

Returns:

A translation vector as a tuple of 3 doubles (x, y, z)

add_atom(atom)[source]

Add an atom.

Parameters:

atomccdc.molecule.Atom

Returns:

a copy of the atom which is now in this molecule

add_atoms(iterable)[source]

Add atoms, whether from another molecule or constructed ab initio.

Parameters:

iterable – any iterable of ccdc.molecule.Atom

Returns:

a tuple of copies of the atoms in iterable

add_bond(bond_type, atom1, atom2)[source]

Add a bond between two atoms.

Parameters:
add_bonds(iterable)[source]

Add several bonds to the molecule.

Parameters:

iterable – should be an iterable of triples, (ccdc.molecule.Bond.BondType, ccdc.molecule.Atom, ccdc.molecule.Atom) where the atoms must be in this molecule

add_group(mol, atom1, atom2)[source]

Add a group from another molecule.

All atoms and bonds of downstream of the pair atom1, atom2 will be added to the molecule.

Parameters:
add_hydrogens(mode='all', add_sites=True)[source]

Add hydrogen atoms to the molecule.

Parameters:
  • mode – ‘all’ to generate all hydrogens (throws away existing hydrogens) or ‘missing’ to generate hydrogens deemed to be missing.

  • add_sites – ‘True’ to generate 3D coordinates for hydrogens (default) ‘False’ to only generate siteless atoms

Raises:

RuntimeError if any heavy atom has no site.

Raises:

RuntimeError if any atoms are of unknown type.

Raises:

RuntimeError if any bonds are of unknown type.

add_molecule(molecule)[source]

Add a copy of all the atoms and bonds of molecule.

Parameters:

moleculeccdc.molecule.Molecule

property all_atoms_have_sites

Whether all atoms have coordinates.

apply_quaternion(Q)[source]

Apply a Quaternion to the molecule, rotating it about an arbitrary axis.

Parameters:

Q – a sequence of 4 floats

Raises:

RuntimeError if an atom has no coordinates

assign_bond_types(which='All')[source]

Assign bond types to the molecule.

Parameters:

which – may be ‘all’ or ‘unknown’

Raises:

ValueError if an unrecognised which parameter is provided

assign_partial_charges()[source]

Assigns partial charges to atoms using the Gasteiger-Marsili algorithm.

Reference: Gasteiger J.; Marsili M., Tetrahedron 36 (22) 3219-3228 1980.

This is a fast, convergent algorithm only suitable for organic molecules.

Returns:

bool, indicating success or failure of the algorithm.

atom(label)[source]

The unique atom with this label.

Parameters:

label – a string

Raises:

RuntimeError if there is not exactly one atom in the molecule with this label

Returns:

ccdc.molecule.Atom

property atoms

List of the atoms in the molecule.

bond(label1, label2)[source]

The bond between the atoms uniquely so labelled.

Parameters:

label2 (label1,) – strings

Raises:

RuntimeError if the atom labels are not unique or the atoms are not bonded

Returns:

ccdc.molecule.Bond

property bonds

List of the bonds in the molecule.

centre_of_geometry()[source]

Geometric centre of the molecule.

Raises:

RuntimeError if an atom has no coordinates

change_group(atom1, atom2, mol, atom3, atom4)[source]

Transfer a copy of a group of atoms and bonds.

All atoms downstream of atom1 - atom2 will be removed and copies of all atoms and bonds downstream of atom3 - atom4 will be added to the molecule. The geometry of the copied atoms will be translated and rotated such that the bond atom3 - atom4 is aligned with atom1 - atom2.

The bond connecting the groups will have the same type as that between atom1 and atom2.

Parameters:
Raises:

RuntimeError if any atom of mol is siteless, or if the bond atom3 - atom4 is cyclic.

Returns:

a tuple of ccdc.molecule.Atom which are the newly added atoms of the molecule.

property components

List of the disconnected molecules with the molecule.

contacts(distance_range=(-5.0, 0.0), only_strongest=False, path_length_range=(4, 999))[source]

The collection of short nonbonded contacts in this molecule.

Distance limits for nonbonded contacts are defined as distances relative to the sum of van der Waals Radii, i.e.:

v(X) + v(Y) - p < d(X…Y) < v(X) + v(Y) - q

where v(X) and v(Y) are the vdW radii of X and Y respectively and p and q are user-specified values in Angstroms (e.g., if p = 0.5 and q = 0.1, the contact must be at least 0.1 Angstroms shorter than the sum of vdW radii but no more than 0.5 Angstroms shorter).

Standard van der Waals radii are assigned to the common elements. They are taken from Bondi, J.Phys.Chem., 68, 441, 1964. Other elements are assigned van der Waals radii of 2.0 Angstroms.

Parameters:
  • distance_range – Minimum and maximum values (Van der Waals corrected) for a short contact (Angstroms).

  • only_strongest – whether to return only the strongest contact made.

  • path_length_range – Minimum and maximum values for length of path between the contact atoms.

property contains_unknown_bonds

Whether the molecule contains unknown bonds.

copy()[source]

Return a deep copy of the molecule.

property formal_charge

The formal charge of the molecule represented as an integer.

property formula

Return the chemical formula of the molecule.

static from_string(s, format='')[source]

Create a molecule from a string representation.

The format will be auto-detected if not specified.

Parameters:
  • s – molecule string representation

  • format – one of ‘mol2’, ‘sdf’, ‘mol’, ‘cif’, ‘mmcif’ or ‘smiles’

Return type:

ccdc.molecule.Molecule

Raises:

TypeError if the format string is not ‘’, ‘mol2’, ‘sdf’, ‘mol’, ‘cif’, ‘mmcif’ or ‘smiles’.

Raises:

RuntimeError if the string representation is incorrectly formatted

fuse_rings(atom1, atom2, mol, atom3, atom4)[source]

Fuse a copy of a ring system.

The bond between atom3 and atom4 will be superimposed on the bond between atom1 and atom2.

Parameters:
Raises:

RuntimeError if bonds between atoms are not cyclic

Returns:

a tuple of ccdc.molecule.Atom which are the newly added atoms of the molecule

generate_inchi(include_stereo=True, add_hydrogens=True)[source]

Return a ccdc.descriptors.MolecularDescriptors.InChIGenerator.InChI object for the molecule

Parameters:
  • include_stereo – include stereochemistry (True, default) or ignore stereochemistry (False) when generating the InChI object

  • add_hydrogens – add hydrogens (True, default) or not add hydrogens (False) when generating the InChI object

Returns:

a ccdc.descriptors.MolecularDescriptors.InChIGenerator.InChI object

property has_charged_atoms

Does molecule contain charged atoms.

hbonds(distance_range=(-5.0, 0.0), angle_tolerance=120.0, vdw_corrected=True, require_hydrogens=True, path_length_range=(4, 999), hbond_criterion=None)[source]

The collection of molecular hydrogen bonds in this molecule.

The definition of a hydrogen bond (D-H…A) is a contact meeting the following criteria:

  • The donor (D) must be a nitrogen, oxygen or sulphur atom covalently bound to at least one hydrogen.

  • The acceptor (A) must be a nitrogen, oxygen, sulphur or halogen with at least one available lone pair (e.g., pyramidal trigonal nitrogen is regarded as an acceptor but planar trigonal nitrogen is not).

  • The D…A distance must be less than the sum of van der Waals Radii of the D and A atoms (vdw_corrected is True) or within the absolute specified range (vdw_corrected is False) in Angstroms.

  • The D-H…A angle must be within the specified angle_tolerance range.

  • The contact may be intermolecular and/or intramolecular involving donor and acceptor atoms separated with covalent bonds within the specified path length.

If hydrogens are not required, they will not appear in the returned ccdc.molecule.Molecule.HBond.atoms.

Parameters:
  • distance_range – Minimum and maximum distances considered acceptable for a hydrogen bond to be formed.

  • vdw_corrected – Whether the distances are relative to the Van der Waals radius of the atoms (Angstroms).

  • angle_tolerance – Acceptable range for a hydrogen Donor-Hydrogen-Acceptor angle (degrees).

  • require_hydrogens – whether hydrogens are necessary for the hydrogen bond.

  • path_length_range – Minimum and maximum values for length of path between donor and acceptor atom. If it is desirable to detect hydrogen bonds spanning discrete components of the molecule, this should be set to (-1, 999).

  • hbond_criterion – an instance of ccdc.molecule.Molecule.HBondCriterion or None. If this is not None then it will be used to override all of the other parameters.

Returns:

a tuple of ccdc.molecule.Molecule.HBond

property heaviest_component

The heaviest component, useful for stripping solvents.

property heavy_atoms

List of the heavy atoms in the molecule.

property identifier

The string identifier of the molecule, e.g. ‘ABEBUF’.

property is_3d

Whether the molecule has 3d coordinates for all heavy atoms.

property is_organic

Uses CSD definitions for organometallic molecules.

property is_organometallic

Uses CSD definitions for organometallic molecules.

property is_polymeric

Whether the molecule contains polymeric bonds.

kekulize()[source]

Convert the molecule to a Kekule representation, replacing all aromatic bonds by alternating single and double bonds.

property largest_ring_size

The size of the largest basic ccdc.molecule.Ring in the molecule.

Returns:

the size of the largest basic ccdc.molecule.Ring or None if there are no rings in the molecule.

property molecular_volume

The molecular volume of the molecule.

property molecular_weight

The molecular weight of the molecule.

normalise_atom_order()[source]

Reorder the atoms of the molecule canonically.

This will not work for structures with unknown atoms or bonds.

This may be useful for comparing polymorphs, for example:

>>> from ccdc import io
>>> csd = io.MoleculeReader('csd')
>>> hxacan = csd.molecule('HXACAN')
>>> hxacan26 = csd.molecule('HXACAN26')
>>> all(a.label == b.label for a, b in zip(hxacan.atoms, hxacan26.atoms))
False
>>> hxacan.normalise_atom_order()
>>> hxacan.normalise_labels()
>>> hxacan26.normalise_atom_order()
>>> hxacan26.normalise_labels()
>>> all(a.label == b.label for a, b in zip(hxacan.atoms, hxacan26.atoms))
True
normalise_hydrogens()[source]

Normalise the hydrogen atom positions in the molecule.

This will normalise the position of hydrogen atoms attached to oxygen, nitrogen or carbon atoms to standard X-H distance values derived from statistical surveys of neutron diffraction data.

Note that this function will only modify the X-H distance. In other words the bond vector direction will be unaffected.

normalise_labels()[source]

Ensure labels of atoms are unique.

Labels will be the atom’s atomic symbol followed by an integer.

remove_atom(atom)[source]

Remove an atom from the molecule.

Parameters:

atomccdc.molecule.Atom which must be in the molecule.

Raises:

RuntimeError if atom is not in the molecule.

remove_atoms(iterable)[source]

Remove several atoms from the molecule.

Parameters:

iterable – any iterable of ccdc.molecule.Atom

Raises:

RuntimeError if any atom is not in the molecule.

remove_bond(bond)[source]

Remove a bond.

Parameters:

bondccdc.molecule.Bond which must be in the molecule

Raises:

RuntimeError if the bond is not present

remove_bonds(iterable)[source]

Remove bonds.

Parameters:

iterable – any iterable of ccdc.molecule.Bond

Raises:

RuntimeError if any bond is not in the molecule

remove_group(atom1, atom2)[source]

Remove the group of atoms and bonds downstream from atom1, atom2.

Parameters:

atom2 (atom1) – ccdc.molecule.Atom which must be in the molecule.

remove_hydrogens()[source]

Remove all hydrogen atoms.

remove_partial_charges()[source]

Removes partial charges from all atoms.

remove_unknown_atoms()[source]

Remove all atoms with an atomic number of zero (e.g. lone pairs, dummy atoms).

property rings

The collection of basic ccdc.molecule.Ring in the molecule.

rotate(xyz, theta)[source]

Rotate a molecule about the vector xyz by theta degrees.

The molecule will be rotated about its centre of geometry.

Parameters:
  • xyz – the rotation axis, a sequence of length 3

  • theta – angle by which to rotate, in degrees

set_bond_length(atom1, atom2, distance)[source]

Set the bond length between the two atoms to distance.

Parameters:
  • atom2 (atom1,) – ccdc.molecule.Atom

  • distance – the desired distance between atom1 and atom2

Raises:

RuntimeError if the two atoms are not neighbours or if the bond between them is cyclic or if an affected atom has no coordinates

set_coordinates(mol, atoms=None)[source]

Set the coordinates of this molecule to those of the other molecule.

For example AACFAZ has no coordinates, so in some circumstances one might wish to use the coordinates from AACFAZ10.

Parameters:
  • mol – another molecule

  • atoms – an iterable of pairs of atoms, the first of which is in this molecule, the second in the other molecule. If this is empty (or None) then it is assumed that the molecules’ atoms match exactly.

set_formal_charges()[source]

Calculate formal charges for atoms assuming bond types and protonation are correct.

set_residue_by_component()[source]

Sets the residue label of disconnected components of the molecule.

set_torsion_angle(atom1, atom2, atom3, atom4, theta)[source]

Set the torsion angle between the specified atoms to theta.

Parameters:
Raises:

RuntimeError if the atoms are not connected or if a bond is cyclic or if an affected atom has no coordinates.

set_valence_angle(atom1, atom2, atom3, theta)[source]

Set the valence angle subtended by atom1, atom2, atom3 to theta.

Parameters:
Raises:

RuntimeError if the atoms are not connected, if either bond is cyclic, or if an affected atom has no coordinates.

shortest_path(atom1, atom2)[source]

Return the shortest path between two atoms.

Parameters:
Returns:

integer of shortest path, or 0 if no path can be found.

Raises:

TypeError if atoms are not in this molecule.

shortest_path_atoms(atom1, atom2)[source]

The list of atoms along the shortest path from atom1 to atom2.

Parameters:
Returns:

list of ccdc.molecule.Atom instances

Raises:

TypeError if atoms are not in this molecule.

shortest_path_bonds(atom1, atom2)[source]

The list of bonds along the shortest path from atom1 to atom2.

Parameters:
Returns:

list of ccdc.molecule.Bond instances

Raises:

TypeError if atoms are not in this molecule.

property smallest_ring_size

Size of the smallest ccdc.molecule.Ring in the molecule.

Returns:

the size of the smallest ccdc.molecule.Ring or None if there are no rings in the molecule.

property smiles

The canonical SMILES representation of the molecule.

This will raise a RuntimeError if the molecule contains unknown atoms or bonds, delocalised bonds or if there are non-terminal hydrogens.

standardise_aromatic_bonds()[source]

Standardise aromatic bonds to CSD conventions.

standardise_delocalised_bonds()[source]

Standardise delocalised bonds to CSD conventions.

to_string(format='mol2')[source]

Return a string representation of a molecule.

Parameters:

format – ‘mol2’, ‘sdf’, ‘mol’, ‘cif’, ‘mmcif’ or ‘smiles’

Return type:

string

Raises:

TypeError if the format string is not ‘mol2’, ‘sdf’, ‘mol’, ‘cif’, ‘mmcif’ or ‘smiles’.

transform(M)[source]

Apply a matrix to the coordinates of the molecule.

The method will not check that the matrix is appropriate for a molecular transformation; it is for the user to ensure that inappropriate affine transformations are avoided.

Parameters:

M – a sequence of length 4 of sequences of length 4 of floats

translate(xyz)[source]

Translate the molecule.

Parameters:

xyz – a sequence of three floats