pywindow.Molecule

class pywindow.Molecule(mol, system_name, mol_id)[source]

Bases: object

Container for a single molecule.

This class is meant for the analysis of single molecules, molecular pores especially. The object passed to this class should therefore be a finite and interconnected individuum.

This class should not be initialised directly, but result from MolecularSystem.system_to_molecule() or MolecularSystem.make_modular().

Methods in Molecule allow to calculate:

  1. The maximum diameter of a molecule.

  2. The average diameter of a molecule.

  3. The intrinsic void diameter of a molecule.

  4. The intrinsic void volume of a molecule.

  5. The optimised intrinsic void diameter of a molecule.

  6. The optimised intrinsic void volume of a molecule.

  7. The circular diameter of a window of a molecule.

Parameters:
mol

dict The Molecular.System.system dictionary passed to the Molecule which is esentially a container of the information that compose a molecular entity, such as the coordinates and atom ids and/or elements.

no_of_atoms

int The number of atoms in the molecule.

elements

numpy.array An array containing the elements, as strings, composing the molecule.

atom_ids

numpy.array (conditional) If the Molecule.mol contains ‘atom_ids’ keyword, the force field ids of the elements.

coordinates

numpy.array The x, y and z atomic Cartesian coordinates of all elements.

parent_system

str The name of MolecularSystem passed to Molecule.

molecule_id

any The molecule id passed when initialising Molecule.

properties

dict A dictionary that is populated by the output of Molecule methods.

Methods

calculate_average_diameter

Return the average diamension of a molecule.

calculate_centre_of_mass

Return the xyz coordinates of the centre of mass of a molecule.

calculate_maximum_diameter

Return the maximum diamension of a molecule.

calculate_pore_diameter

Return the intrinsic pore diameter.

calculate_pore_diameter_opt

Return the intrinsic pore diameter (for the optimised pore centre).

calculate_pore_volume

Return the intrinsic pore volume.

calculate_pore_volume_opt

Return the intrinsic pore volume (for the optimised pore centre).

calculate_windows

Return the diameters of all windows in a molecule.

dump_molecule

Dump a Molecule to a file (PDB or XYZ).

dump_properties_json

Dump content of Molecule.properties to a JSON dictionary.

full_analysis

Perform a full structural analysis of a molecule.

load_rdkit_mol

Create a Molecule from rdkit.Chem.rdchem.Mol.

molecular_weight

Return the molecular weight of a molecule.

shift_to_origin

Shift a molecule to Origin.

classmethod load_rdkit_mol(mol, system_name='rdkit', mol_id=0)[source]

Create a Molecule from rdkit.Chem.rdchem.Mol.

To be used only by expert users.

Parameters:
  • mol (rdkit.Chem.rdchem.Mol) – rdkit.Chem.rdchem.Mol An RDKit molecule object.

  • system_name (str)

  • mol_id (int)

Returns:

pywindow.Molecule

Return type:

Molecule

calculate_average_diameter()[source]

Return the average diamension of a molecule.

Returns:

The average dimension of the molecule.

Return type:

float

calculate_centre_of_mass()[source]

Return the xyz coordinates of the centre of mass of a molecule.

Returns:

The centre of mass of the molecule.

Return type:

ndarray

calculate_maximum_diameter()[source]

Return the maximum diamension of a molecule.

Returns:

The maximum dimension of the molecule.

Return type:

float

calculate_pore_diameter()[source]

Return the intrinsic pore diameter.

Returns:

The intrinsic pore diameter.

Return type:

float

calculate_pore_diameter_opt()[source]

Return the intrinsic pore diameter (for the optimised pore centre).

Similarly to calculate_pore_diameter() this method returns the the intrinsic pore diameter, however, first a better approximation of the pore centre is found with optimisation.

Returns:

The intrinsic pore diameter.

Return type:

float

calculate_pore_volume()[source]

Return the intrinsic pore volume.

Returns:

The intrinsic pore volume.

Return type:

float

calculate_pore_volume_opt()[source]

Return the intrinsic pore volume (for the optimised pore centre).

Similarly to calculate_pore_volume() this method returns the the volume intrinsic pore diameter, however, for the calculate_pore_diameter_opt() returned value.

Returns:

The intrinsic pore volume.

Return type:

float

calculate_windows(ncpus=1)[source]

Return the diameters of all windows in a molecule.

This function first finds and then measures the diameters of all the window in the molecule.

Returns:

An array of windows’ diameters. Or, None, ff no windows were found.

Parameters:

ncpus (int)

Return type:

ndarray | None

dump_molecule(filepath=None, include_coms=False, override=False)[source]

Dump a Molecule to a file (PDB or XYZ).

For validation purposes an overlay of window centres and COMs can also be dumped as:

He - for the centre of mass

Ne - for the centre of the optimised cavity

Ar - for the centres of each found window

Parameters:
  • filepath (Path | str | None) – The filepath for the dumped file. If None, the file is dumped locally with molecule_id as filename. (default=None)

  • include_coms (bool) – If True, dump also with an overlay of window centres and COMs. (default=False)

  • override (bool) – If True, any file in the filepath will be override. (default=False)

Return type:

None

dump_properties_json(filepath=None, molecular=False, override=False)[source]

Dump content of Molecule.properties to a JSON dictionary.

Parameters:
  • filepath (Path | str | None) – The filepath for the dumped file. If None, the file is dumped localy with molecule_id as filename. (defualt=None)

  • molecular (bool) – If False, dump only the content of Molecule.properties, if True, dump all the information about Molecule.

  • override (bool) – If True, any file in the filepath will be override. (default=False)

Return type:

None

full_analysis(ncpus=1)[source]

Perform a full structural analysis of a molecule.

This invokes other methods:

Parameters:

ncpus (int) – int Number of CPUs used for the parallelised parts of pywindow.utilities.find_windows(). (default=1=serial)

Returns:

Molecule.properties

The updated Molecule.properties with returns of all used methods.

Return type:

dict

molecular_weight()[source]

Return the molecular weight of a molecule.

Returns:

float

The molecular weight of the molecule.

Return type:

float

shift_to_origin()[source]

Shift a molecule to Origin.

This function takes the molecule’s coordinates and adjust them so that the centre of mass of the molecule coincides with the origin of the coordinate system.

Returns:

NoneType

Return type:

None