Tools

Structure Generation Tools

molSimplify.Scripts.structgen.align_dent1_lig(args, cpoint, core3D, coreref, ligand, lig3D, catoms, rempi=False, ligpiatoms=[], MLb=[], ANN_flag=False, ANN_bondl: float = nan, this_diag=0, MLbonds={}, MLoptbds: List[float] | None = None, i: int = 0, EnableAutoLinearBend=True) Tuple[mol3D, List[float]][source]

Aligns a monodentate ligand to core connecting atom coordinates.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • cpoint (atom3D) – atom3D class instance containing backbone connecting point.

  • core3D (mol3D) – mol3D class instance of partially built complex.

  • coreref (atom3D) – atom3D of core reference atom.

  • ligand (str) – Name of ligand for dictionary lookup.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • catoms (list) – List of ligand connecting atom indices.

  • rempi (bool, optional) – Flag for pi-coordinating ligand. Default is False.

  • ligpiatoms (list, optional) – List of pi-coordinating atom indices in ligand. Default is empty.

  • MLb (list, optional) – Custom M-L bond length (if any). Default is empty.

  • ANN_flag (bool, optional) – Flag for ANN activation. Default is False.

  • this_diag (run_diag, optional) – ANN run_diag class instance. Default is 0.

  • MLbonds (dict, optional) – M-L bond dictionary. Default is empty.

  • MLoptbds (list, optional) – List of final M-L bond lengths. Default is None.

  • i (int, optional) – Ligand serial number. Default is 0.

  • EnableAutoLinearBend (bool, optional) – Flag for enabling automatic bending of linear ligands (e.g. superoxo).

Returns:

  • lig3D_aligned (mol3D) – mol3D class instance of aligned ligand.

  • MLoptbds (list) – Updated list of metal ligand bonds.

molSimplify.Scripts.structgen.align_dent2_catom2_coarse(args, lig3D, core3D, catoms, r1, r0, m3D, batoms, corerefcoords)[source]

Crude rotations to improve alignment of the 2nd connecting atom of a bidentate substrate.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • core3D (mol3D) – mol3D class instance of partially built complex.

  • catoms (list) – List of ligand connecting atom indices.

  • r1 (list) – Coordinates of ligand first connecting atom.

  • r0 (list) – Coordinates of core reference point.

  • m3D (mol3D) – mol3D class instance of backbone template.

  • batoms (list) – List of backbone atom indices.

  • corerefcoords (list) – Coordinates of core reference atom.

Returns:

  • lig3D_aligned (mol3D) – mol3D class instance of aligned ligand.

  • r1b (list) – Coordinates of second backbone point.

molSimplify.Scripts.structgen.align_dent2_catom2_refined(args, lig3D, catoms, bondl, r1, r0, core3D, rtarget, coreref, MLoptbds)[source]

Aligns second connecting atom of a bidentate ligand to balance ligand strain and the desired coordination environment.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • catoms (list) – List of ligand connecting atom indices.

  • bondl (float) – Target M-L bond length.

  • r1 (list) – Coordinates of ligand first connecting atom.

  • r0 (list) – Coordinates of core reference point.

  • core3D (mol3D) – mol3D class instance of partially built complex.

  • rtarget (list) – Coordinates of target point for second connecting atom.

  • coreref (atom3D) – atom3D of core reference atom.

  • MLoptbds (list) – List of final M-L bond lengths.

Returns:

lig3D_aligned – mol3D class instance of aligned ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.align_dent2_lig(args, cpoint, batoms, m3D, core3D, coreref, ligand, lig3D, catoms, MLb, ANN_flag, ANN_bondl: float, this_diag, MLbonds, MLoptbds: List[float], frozenats: List[int], i: int) Tuple[mol3D, List[int], List[float]][source]

Aligns a bidentate ligand to core connecting atom coordinates.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • cpoint (atom3D) – atom3D class instance containing backbone connecting point.

  • batoms (list) – List of backbone atom indices.

  • m3D (mol3D) – mol3D of backbone template.

  • core3D (mol3D) – mol3D class instance of partially built complex.

  • coreref (atom3D) – atom3D of core reference atom.

  • ligand (str) – Name of ligand for dictionary lookup.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • catoms (list) – List of ligand connecting atom indices.

  • MLb (list) – Custom M-L bond length (if any).

  • ANN_flag (bool) – Flag for ANN activation.

  • ANN_bondl (list) – List of ANN predicted bond lengths.

  • this_diag (run_diag) – ANN run_diag class instance.

  • MLbonds (dict) – M-L bond dictionary.

  • MLoptbds (list) – List of final M-L bond lengths.

  • frozenats (list) – List of atoms frozen in FF optimization.

  • i (int, optional) – Ligand serial number. Default is 0.

Returns:

  • lig3D_aligned (mol3D) – mol3D class instance of aligned ligand.

  • frozenats (list) – List of frozen atoms.

  • MLoptbds (list) – Updated list of metal ligand bonds.

molSimplify.Scripts.structgen.align_dent3_lig(args, cpoint, batoms, m3D, core3D, coreref, ligand, lig3D, catoms, MLb, ANN_flag, ANN_bondl, this_diag, MLbonds, MLoptbds: List[float], frozenats: List[int], i: int) Tuple[mol3D, List[int], List[float]][source]

Aligns a tridentate ligand to core connecting atom coordinates

Parameters:
  • args (Namespace) – Namespace of arguments.

  • cpoint (atom3D) – atom3D class instance containing backbone connecting point.

  • batoms (list) – List of backbone atom indices.

  • m3D (mol3D) – mol3D of backbone template.

  • core3D (mol3D) – mol3D class instance of partially built complex.

  • coreref (atom3D) – atom3D of core reference atom.

  • ligand (str) – Name of ligand for dictionary lookup.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • catoms (list) – List of ligand connecting atom indices.

  • MLb (list) – Custom M-L bond length (if any).

  • ANN_flag (bool) – Flag for ANN activation.

  • ANN_bondl (list) – List of ANN predicted bond lengths.

  • this_diag (run_diag) – ANN run_diag class instance.

  • MLbonds (dict) – M-L bond dictionary.

  • MLoptbds (list) – List of final M-L bond lengths.

  • frozenats (list) – List of atoms frozen in FF optimization.

  • i (int, optional) – Ligand serial number. Default is 0.

Returns:

  • lig3D_aligned (mol3D) – mol3D class instance of aligned ligand.

  • frozenats (list) – List of frozen atoms.

  • MLoptbds (list) – Updated list of metal ligand bonds.

molSimplify.Scripts.structgen.align_lig_centersym(corerefcoords, lig3D, atom0, core3D, EnableAutoLinearBend)[source]

Aligns a ligand’s center of symmetry along the metal-connecting atom axis

Parameters:
  • corerefcoords (list) – Core reference coordinates.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index.

  • core3D (mol3D) – mol3D instance of partially built complex.

  • EnableAutoLinearBend (bool) – Flag for enabling automatic bending of linear ligands (e.g. superoxo).

Returns:

lig3D_aligned – mol3D class instance of aligned ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.align_linear_pi_lig(corerefcoords, lig3D, atom0, ligpiatoms)[source]

Aligns a linear pi ligand’s connecting point to the metal-ligand axis.

Parameters:
  • corerefcoords (list) – Core reference coordinates.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index.

  • ligpiatoms (list) – List of ligand pi-connecting atom indices.

Returns:

lig3D_aligned – mol3D class instance of aligned ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.align_pi_ring_lig(corerefcoords, lig3D, atom0, ligpiatoms, u)[source]

Rotates the ligand such that the aromatic ring that bonds to the central metal is perpendicular to the vector from the metal to the fictitous atom in the center of the ring.

Parameters:
  • corerefcoords (list) – Core reference coordinates. These are the coordinates of the central metal.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index. Here, refers to the fictitious atom in the center of the aromatic ring, since we have a ligand that coordinates through an aromatic ring.

  • ligpiatoms (list) – List of ligand pi-connecting atom indices.

  • u (list) – Vector from the metal to the fictitious atom in the center of the aromatic ring. Length is 3.

Returns:

lig3D – mol3D class instance of aligned ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.check_rotate_linear_lig(corerefcoords, lig3D, atom0)[source]

Checks if ligand has a linear coordination environment (e.g., OCO) and ensures perpendicularity to M-L axis

Parameters:
  • corerefcoords (list) – Core reference coordinates.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index.

Returns:

lig3D_aligned – mol3D class instance of rotated ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.check_rotate_symm_lig(corerefcoords, lig3D, atom0, core3D)[source]

Aligns a ligand’s center of symmetry along the metal-connecting atom axis

Parameters:
  • corerefcoords (list) – Core reference coordinates.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index.

  • core3D (mol3D) – mol3D instance of partially built complex.

Returns:

lig3D_aligned – mol3D class instance of rotated ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.distortbackbone(backb, distort)[source]

Randomly distorts backbone.

Parameters:
  • backb (List) – List with points comprising the backbone.

  • distort (float) – Percentage of backbone to be distorted.

Returns:

backb – List of distorted backbone points.

Return type:

list

molSimplify.Scripts.structgen.ffopt(ff: str, mol: mol3D, connected: List[int], constopt: int, frozenats: List[int], frozenangles: bool, mlbonds: List[float], nsteps: int | str, spin: int = 1, debug: bool = False) Tuple[mol3D, float][source]

Main constrained FF opt routine.

Parameters:
  • ff (str) – Name force field to use. Available options are MMFF94, UFF, Ghemical, GAFF, XTB. (XTB only works if the xtb command-line program is installed.)

  • mol (mol3D) – mol3D instance of molecule to be optimized.

  • connected (list) – List of indices of connection atoms to metal.

  • constopt (int) – Flag for constrained optimization - 0: unconstrained, 1: fixed connecting atom positions, 2: fixed connecting atom distances.

  • frozenats (list) – List of frozen atom indices.

  • frozenangles (bool) – Flag for frozen angles, equivalent to constopt==1.

  • mlbonds (list) – List of M-L bonds for distance constraints.

  • nsteps (int) – Number of steps to take.

  • spin (int) – Spin multiplicity

  • debug (bool) – Flag to print extra info to debug.

Returns:

  • mol (mol3D) – Optimized molecule mol3D instance.

  • en (float) – Forcefield energy of optimized molecule.

molSimplify.Scripts.structgen.findsmarts(lig3D: mol3D, smarts: List[str], catom: int) bool[source]

Checks if connecting atom of lig3D is part of SMARTS pattern.

Parameters:
  • lig3D (OBMol) – OBMol class instance of ligand. Use convert2OBMol mol3D bound method to obtain it.

  • smarts (list) – List of SMARTS patterns (strings).

  • catom (int) – connecting atom of lig3D (zero based numbering).

Returns:

SMARTS_flag – SMARTS match flag. True if found, False if not.

Return type:

bool

molSimplify.Scripts.structgen.generate_report(args: Namespace, ligands: List[str], ligoc: List[int]) Tuple[mol3D, List[mol3D], str, run_diag, List[int], List[int]][source]
molSimplify.Scripts.structgen.get_MLdist(metal: atom3D, oxstate: str, spin: str, lig3D: mol3D, atom0: int, ligand: str, MLb: List[str], i: int, ANN_flag: bool, ANN_bondl: float, this_diag: run_diag, MLbonds: dict, debug: bool = False) float[source]

Gets target M-L distance from desired source (custom, sum cov rad or ANN). Aligns a monodentate ligand to core connecting atom coordinates.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index.

  • ligand (str) – Name of ligand for dictionary lookup.

  • metal (atom3D) – atom3D class instance of the first atom (usually a metal).

  • MLb (float) – Custom M-L bond length (if any).

  • i (int) – Ligand index number.

  • ANN_flag (bool) – Flag for ANN activation.

  • ANN_bondl (float) – ANN predicted M-L bond length.

  • this_diag (run_diag) – run_diag instance for ANN diagnostic object.

  • MLbonds (dict) – M-L bond dictionary.

Returns:

bondl – M-L bond length in angstroms.

Return type:

float

molSimplify.Scripts.structgen.get_MLdist_database(metal: atom3D, oxstate: str, spin: str, lig3D: mol3D, atom0: int, ligand: str, MLbonds: dict, debug=False) Tuple[float, bool][source]

Gets target M-L distance from desired source (custom, sum cov rad or ANN). Aligns a monodentate ligand to core connecting atom coordinates.

Parameters:
  • metal (atom3D) – atom3D class instance of the first atom (usually a metal).

  • oxstate (str:) – oxidation state

  • spin (str) – spin state

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index.

  • ligand (str) – Name of ligand for dictionary lookup.

  • MLbonds (dict) – M-L bond dictionary.

Returns:

  • bondl (float) – M-L bond length in angstroms.

  • exact_match (bool) – Flag for database match.

molSimplify.Scripts.structgen.get_batoms(args, batslist, ligsused)[source]

Get backbone atoms from template.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • batslist (list) – List of backbone connecting atoms for each ligand.

  • ligsused (int) – Number of ligands placed.

Returns:

batoms – Backbone connecting atoms for ligand.

Return type:

list

molSimplify.Scripts.structgen.getbackbcombsall(nums)[source]

Gets all possible combinations for connection atoms in geometry in the case of forced order or unknown geometry.

Parameters:

nums (list) – List of connection atoms.

Returns:

bbcombs – List of possible backbone atom combinations.

Return type:

list

molSimplify.Scripts.structgen.getconnection(core: mol3D, cidx: int, BL: float) List[float][source]

Finds the optimum attachment point for an atom/group to a central atom given the desired bond length. Objective function maximizes the minimum distance between attachment point and other groups bonded to the central atom.

Parameters:
  • core (mol3D) – mol3D class instance of the core.

  • cidx (int) – Core connecting atom index.

  • BL (float) – Optimal core-ligand bond length.

Returns:

cpoint – Coordinates of attachment point.

Return type:

list

molSimplify.Scripts.structgen.getnupdateb(backbatoms: List[List[int]], denticity: int) Tuple[List[int], List[List[int]]][source]

Gets a combination of backbone points that satisfies denticity and updates possible combinations.

Parameters:
  • backbatoms (list) – List of possible backbone atom combinations.

  • denticity (int) – Denticity of ligand.

Returns:

  • batoms (list) – Selected combination of backbone atoms.

  • backbatoms (list) – Updated list of possible backbone atom combinations.

molSimplify.Scripts.structgen.init_ANN(args, ligands: List[str], occs: List[int], dents: List[int], batslist: List[List[int]], tcats: List[List[str | int]], licores: dict) Tuple[bool, List[Any], str, Dict[str, Any], bool][source]

Initializes ANN.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • ligands (list) – List of ligands, given as names.

  • occs (list) – List of ligand occupations (frequencies of each ligand).

  • dents (list) – List of ligand denticities.

  • batslist (list) – List of backbond points.

  • tcats (list) – List of SMILES ligand connecting atoms.

  • licores (dict) – Ligand dictionary within molSimplify.

Returns:

  • ANN_flag (bool) – Whether an ANN call was successful.

  • ANN_bondl (float) – ANN predicted bond length.

  • ANN_reason (str) – Reason for ANN failure, if failed.

  • ANN_attributes (dict) – Dictionary of predicted attributes of complex.

  • catalysis_flag (bool) – Whether or not complex is compatible for catalytic ANNs.

molSimplify.Scripts.structgen.init_ligand(args: Namespace, lig: mol3D, tcats, keepHs: List[List[bool | str]], i: int)[source]

Initializes ligand 3D geometry and properties.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • lig (mol3D) – mol3D instance of the ligand.

  • tcats (list) – List of SMILES ligand connecting atoms.

  • keepHs (bool) – Flag for keeping H atoms on connecting atoms.

  • i (int) – Ligand index.

Returns:

  • lig3D (mol3D) – Ligand mol3D instance.

  • rempi (bool) – Flag for pi coordination.

  • ligpiatoms (list) – List of pi coordinating atoms.

molSimplify.Scripts.structgen.init_template(args: Namespace, cpoints_required: int) Tuple[mol3D, mol3D, str, list, int, mol3D][source]

Initializes core and template mol3Ds and properties.

Parameters:
  • args (Namespace) – Namespace of arguments.

  • cpoints_required (int) – Number of connecting points required.

Returns:

  • m3D (mol3D) – Template complex mol3D instance.

  • core3D (mol3D) – Core mol3D instance.

  • geom (str) – Geometry used.

  • backbatoms (list) – List of backbone atoms.

  • coord (int) – Coordination number.

  • corerefatoms (mol3D) – Core reference atom index, mol3D instance.

molSimplify.Scripts.structgen.mcomplex(args: Namespace, ligs: List[str], ligoc: List[int]) Tuple[mol3D, List[mol3D], str, run_diag, List[int], List[int]][source]

Main ligand placement routine

Parameters:
  • args (Namespace) – Namespace of arguments.

  • ligs (list) – List of ligand names.

  • ligoc (list) – List of ligand occupations.

  • licores (dict) – Ligand dictionary as in molSimplify.

Returns:

  • core3D (mol3D) – mol3D class instance for core.

  • complex3D (mol3D) – mol3D class instance for built complex.

  • emsg (str) – Flag for error. String if error, with error message.

  • this_diag (run_diag) – run_diag class instance of the complex.

  • subcatoms_ext (list) – Substrate connection atoms from TSGen. Deprecated.

  • mligcatoms_ext (list) – Ligand connection atoms from TSGen. Deprecated.

molSimplify.Scripts.structgen.modifybackbonep(backb, pangles)[source]

Distorts backbone according to user specified angles.

Parameters:
  • backb (List) – List with points comprising the backbone.

  • pangles (List) – Pairs of theta/phi angles in DEGREES. Should be list of tuples.

Returns:

backb – List of distorted backbone points.

Return type:

list

molSimplify.Scripts.structgen.openbabel_ffopt(ff: str, mol: mol3D, connected: List[int], constopt: int, frozenats: List[int], frozenangles: bool, mlbonds: List[float], nsteps: int | str, debug: bool = False) Tuple[mol3D, float][source]

OpenBabel constraint optimization. To optimize metal-containing complexes with MMFF94, an intricate procedure of masking the metal atoms and manually editing their valences is applied. OpenBabel’s implementation of MMFF94 may run extremely slowly on some systems. If so, consider switching to UFF.

Parameters:
  • ff (str) – Name force field to use. Available options are MMFF94, UFF, Ghemical, GAFF.

  • mol (mol3D) – mol3D instance of molecule to be optimized.

  • connected (list) – List of indices of connection atoms to metal.

  • constopt (int) –

    Flag for constrained optimization

    0: unconstrained, 1: fixed connecting atom positions, 2: fixed connecting atom distances.

  • frozenats (list) – List of frozen atom indices.

  • frozenangles (bool) – Flag for frozen angles, equivalent to constopt==1.

  • mlbonds (list) – List of M-L bonds for distance constraints.

  • nsteps (int) – Number of steps to take.

  • debug (bool) – Flag to print extra info to debug.

Returns:

  • mol (mol3D) – Optimized molecule mol3D instance.

  • en (float) – Forcefield energy of optimized molecule.

molSimplify.Scripts.structgen.rotate_MLaxis_minimize_steric(corerefcoords, lig3D, atom0, core3D)[source]

Rotates aligned ligand about M-L axis to minimize steric clashes with rest of complex

Parameters:
  • corerefcoords (list) – Core reference coordinates.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index.

  • core3D (mol3D) – mol3D instance of partially built complex.

Returns:

lig3D_aligned – mol3D class instance of rotated ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.rotate_catom_fix_Hs(lig3D, catoms, n, mcoords, core3D)[source]

Rotates a connecting atom of a multidentate ligand to improve H atom placement. There are separate routines for terminal connecting atoms and intermediate connecting atoms.

Parameters:
  • lig3D (mol3D) – mol3D class instance of the ligand.

  • catoms (list) – List of ligand connecting atom indices.

  • n (int) – Index of connecting atom.

  • mcoords (list) – Coordinates of a core reference (usually a metal).

  • core3D (mol3D) – mol3D of partially built complex.

Returns:

lig3D_aligned – mol3D class instance of rotated ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.rotate_catoms_fix_Hs(lig3D: mol3D, catoms: List[int], mcoords, core3D: mol3D) mol3D[source]

Rotates connecting atoms of multidentate ligands to improve H atom placement. Loops over rotate_catom_fix_Hs().

Parameters:
  • lig3D (mol3D) – mol3D class instance of the ligand.

  • catoms (list) – List of ligand connecting atom indices.

  • mcoords (list) – Coordinates of a core reference (usually a metal).

  • core3D (mol3D) – mol3D of partially built complex.

Returns:

lig3D_aligned – mol3D class instance of rotated ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.rotation_objective_func(rotations, lig3D, atom0, ligpiatoms, metal_lig_vec, directional_vectors)[source]

Objective function for finding rotations that make an aromatic ring perpendicular to the metal-ligand vector.

Parameters:
  • rotations (list) – Floats that indicate angles by which to rotate the ligand. Length is 3.

  • lig3D (mol3D) – mol3D class instance of the ligand.

  • atom0 (int) – Ligand connecting atom index. Here, refers to the fictitious atom in the center of the aromatic ring.

  • ligpiatoms (list) – List of ligand pi-connecting atom indices.

  • metal_lig_vec (np.array) – Vector from the metal to the fictitious atom in the center of the aromatic ring. Shape is (3,)

  • directional_vectors (list) – Numpy arrays of the x-axis vector, y-axis vector, and z-axis vector. Length is 3.

Returns:

lig3D_aligned – mol3D class instance of aligned ligand.

Return type:

mol3D

molSimplify.Scripts.structgen.smartreorderligs(ligs: List[str], dentl: List[int], ligalign: bool = True) List[int][source]

Smart reorder ligands by denticity (-ligalign True)

Parameters:
  • args (Namespace) – Namespace of arguments.

  • ligs (list) – List of ligands as ligand names.

  • dentl (list) – List of ligand denticities.

Returns:

indices – Reordered ligand indices.

Return type:

list

molSimplify.Scripts.structgen.structgen(args: Namespace, rootdir: str, ligands: List[str], ligoc: List[int], sernum: int, write_files: bool = True) Tuple[List[str], str, run_diag][source]

Main structure generation routine - multiple structures

Parameters:
  • args (Namespace) – Namespace of arguments.

  • rootdir (str) – Directory of current run to generate complex.

  • ligands (list) – List of ligand names.

  • ligoc (list) – List of ligand occupations.

  • sernum (int) – Serial number of complex for naming.

  • write_files (bool, optional) – Flag to write files. Default is True. False for pythonic generation.

Returns:

  • strfiles (str) – List of XYZ files.

  • emsg (str) – Error message for structure generation. If True, has string.

  • this_diag (run_diag) – run_diag class instance containing properties of structure.

molSimplify.Scripts.structgen.xtb_opt(ff: str, mol: mol3D, connected: List[int], constopt: int, frozenats: List[int], frozenangles: bool, mlbonds: List[float], nsteps: int | str, spin: int = 1, inertial: bool = False, debug: bool = False) Tuple[mol3D, float][source]

XTB optimization. Writes an input file (xtb.in) containing all the constraints and parameters to a temporary folder, executes the XTB program using the subprocess module and parses the output.

Parameters:
  • ff (str) – Name force field to use. Only option for now is XTB.

  • mol (mol3D) – mol3D instance of molecule to be optimized.

  • connected (list) – List of indices of connection atoms to metal.

  • constopt (int) – Flag for constrained optimization - 0: unconstrained, 1: fixed connecting atom positions, 2: fixed connecting atom distances.

  • frozenats (list) – List of frozen atom indices.

  • frozenangles (bool) – Flag for frozen angles, equivalent to constopt==1.

  • mlbonds (list) – List of M-L bonds for distance constraints.

  • nsteps (int) – Number of steps to take.

  • spin (int) – Spin multiplicity

  • inertial (bool) – Flag for the fast inertial relaxation engine (FIRE)

  • debug (bool) – Flag to print extra info to debug.

Returns:

  • mol (mol3D) – Optimized molecule mol3D instance.

  • en (float) – Forcefield energy of optimized molecule.

molSimplify.Scripts.generator.startgen(argv, flag, gui, inputfile_str=None, write_files=True)[source]

Coordinates subroutines.

Parameters:
  • argv (list) – Argument list.

  • flag (bool) – Flag for printing information.

  • gui (bool) – Flag for GUI.

  • inputfile_str (str, optional) – Optional input passed in as a string. Default is None.

  • write_files (bool, optional) – Flag for whether or not files should be written. Should set to false for pythonic generation.

Returns:

emsg – Flag for error. If error, returns a string with error.

Return type:

bool

molSimplify.Scripts.generator.startgen_pythonic(input_dict={'-core': 'fe', '-lig': 'cl,cl,cl,cl,cl,cl'}, argv=['main.py', '-i', 'asdfasdfasdfasdf'], flag=True, gui=False, write=False)[source]

This is the main way to generate structures completely within Python.

Parameters:
  • input_dict (dict) – Argument list in the form of a dictionary.

  • argv (list) – Default argument list used to “fool” startgen into accepting input_dict.

  • flag (bool, optional) – Flag for printing information. Default is True.

  • gui (bool, optional) – Flag for GUI. Default is False.

  • write (bool, optional) – Flag to generate outputfile from python

Returns:

  • strfiles (str) – Folder containing the runs.

  • emsg (bool) – Flag for error. If error, returns a string with error.

  • this_diag (rundiag) – Rundiag class instance that contains ANN attributes (this_diag.ANN_attributes) and a mol3D class instance (this_diag.mol).

Geometry Manipulation Tools

molSimplify.Scripts.geometry.PointRotateAxis(u, rp, r, theta)[source]

Rotates point about axis defined by direction vector and point on axis. Theta units in radians.

Parameters:
  • u (list) – Direction vector of axis.

  • rp (list) – Reference point along axis

  • r (list) – Point to be rotated

  • theta (float) – Angle of rotation in RADIANS.

Returns:

rotated – Rotated point.

Return type:

list

molSimplify.Scripts.geometry.PointRotateMat(r, R)[source]

Rotates point using arbitrary 3x3 rotation matrix

Parameters:
  • r (list) – Point to be rotated

  • R (list) – List of lists for 3 by 3 rotation matrix.

Returns:

rotated – Rotated point.

Return type:

list

molSimplify.Scripts.geometry.PointRotateSph(Rp, p0, D)[source]

Rotates point about Cartesian axes defined relative to given origin.

Parameters:
  • Rp (list) – Cartesian origin

  • p0 (list) – Point to be rotated

  • D (list) – [theta-x, theta-y, theta-z] in RADIANS

Returns:

p – Rotated point

Return type:

list

molSimplify.Scripts.geometry.PointTranslateSph(Rp, p0, D) List[float][source]

Translates point in spherical coordinates.

Parameters:
  • Rp (list) – Origin of sphere

  • p0 (list) – Point to be translated

  • D (list) – [final radial distance, change in polar phi, change in azimuthal theta]. Angles in RADIANS.

Returns:

p – Translated point.

Return type:

list

molSimplify.Scripts.geometry.PointTranslateSphgivenphi(Rp, p0, D)[source]

Translates point in spherical coordinates. Redundant with PointTranslateSph. Will be deprecated.

Parameters:
  • Rp (list) – Origin of sphere

  • p0 (list) – Point to be translated

  • D (list) – [final radial distance, change in polar phi, change in azimuthal theta]. Angles in RADIANS.

Returns:

p – Translated point.

Return type:

list

molSimplify.Scripts.geometry.PointTranslateSphgivenr(Rp, p0, D, pref, r)[source]

Translates point in spherical coordinates given R.

Parameters:
  • Rp (list) – Origin of sphere

  • p0 (list) – Point to be translated

  • D (list) – [final radial distance, change in polar phi, change in azimuthal theta]. Angles in RADIANS.

  • pref (list) – Coordinates of reference point.

  • r (float) – Given radius.

Returns:

p – Translated point.

Return type:

list

molSimplify.Scripts.geometry.PointTranslatetoPSph(Rp, p0, D)[source]

Converts spherical translation vector into Cartesian translation vector

Parameters:
  • Rp (list) – Origin of sphere

  • p0 (list) – Point to be translated

  • D (list) – [final radial distance, change in polar phi, change in azimuthal theta]. Angles in RADIANS.

Returns:

p – Translation vector

Return type:

list

molSimplify.Scripts.geometry.ReflectPlane(u, r, Rp)[source]

Reflects point about plane defined by its normal vector and a point on the plane

Parameters:
  • u (list) – Normal vector to plane.

  • r (list) – Point to be reflected.

  • Rp (list) – Reference point on plane.

Returns:

rn – Reflected point.

Return type:

list

molSimplify.Scripts.geometry.alignPtoaxis(Rr, Rp, u, d)[source]

Translates point and aligns to axis

Parameters:
  • Rr (list) – Point to be aligned

  • Rp (list) – Reference point on axis

  • u (list) – Target axis for alignment. Direction vector.

  • d (float) – Final distance from aligned point to axis

Returns:

dxyz – Translation vector

Return type:

list

molSimplify.Scripts.geometry.aligntoaxis(mol, Rr, Rp, u)[source]

Translates molecule to align point to axis at constant distance.

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be translated.

  • Rr (list) – Point to be aligned

  • Rp (list) – Reference point on axis

  • u (list) – Target axis for alignment

Returns:

mol – mol3D class instance of aligned molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.aligntoaxis2(mol, Rr, Rp, u, d)[source]

Translates molecule to align point to axis at arbitrary distance

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be translated.

  • Rr (list) – Point to be aligned

  • Rp (list) – Reference point on axis

  • u (list) – Target axis for alignment

  • d (float) – Final distance from aligned point to axis

Returns:

mol – mol3D class instance of translated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.best_fit_plane(coordinates)[source]

Finds the best fitting plane to a set of atoms at the specified coordinates.

Parameters:

corerefcoords (np.array) – Coordinates of atoms for which the best fitting plane is to be found. Shape is 3 x N.

Returns:

normal_vector_plane – The vector perpendicular to the best fitting plane.

Return type:

np.array

molSimplify.Scripts.geometry.checkcolinear(r1, r2, r3)[source]

Checks if three points are collinear.

Parameters:
  • r1 (list) – Coordinates of point 1.

  • r2 (list) – Coordinates of point 2.

  • r3 (list) – Coordinates of point 3.

Returns:

collinear_flag – Flag for collinearity. True if collinear.

Return type:

bool

molSimplify.Scripts.geometry.checkplanar(r1, r2, r3, r4)[source]

Checks if four points are coplanar.

Parameters:
  • r1 (list) – Coordinates of point 1.

  • r2 (list) – Coordinates of point 2.

  • r3 (list) – Coordinates of point 3.

  • r4 (list) – Coordinates of point 4.

Returns:

coplanar_flag – Flag for coplanarity. True if coplanarity.

Return type:

bool

molSimplify.Scripts.geometry.cmrotate(mol, D)[source]

Rotates molecule about its center of mass Loops over PointRotateSph().

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be rotated.

  • D (list) – [theta-x, theta-y, theta-z] in RADIANS

Returns:

mol – mol3D class instance of rotated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.connectivity_match(inds1, inds2, mol1, mol2)[source]

Check whether the connectivity of two fragments of mols match. Note: This will mark atom transfers between different ligands as False, which may not be correct mathmetically as the graph after atoms transfer can still be the same. We disallow these cases from chemical concerns and avoid the NP-hard porblem of comparing two adjecent matrix.

Parameters:
  • inds1 (list) – List of atom inds in molecule 1.

  • inds2 (list) – List of atom inds in molecule 2.

  • mol1 (mol3D) – mol3D class instance for molecule 1.

  • mol2 (mol3D) – mol3D class instance for molecule 2.

Returns:

match_flag – Flag for if connectivity matches. True if so.

Return type:

bool

molSimplify.Scripts.geometry.dihedral(mol, idx1, idx2, idx3, idx4)[source]

Computes dihedral angle for a set of four atom indices.

Parameters:
  • mol0 (mol3D) – mol3D class instance of molecule for which we compute dihedral angle.

  • idx1 (int) – Index of atom 1.

  • idx2 (int) – Index of atom 2.

  • idx3 (int) – Index of atom 3.

  • idx4 (int) – Index of atom 4.

molSimplify.Scripts.geometry.distance(r1, r2)[source]

Euclidean distance between points.

Parameters:
  • r1 (list) – Coordinates of point 1.

  • r2 (list) – Coordinates of point 2.

Returns:

dist – Euclidean distance between points 1 and 2.

Return type:

float

molSimplify.Scripts.geometry.getPointu(Rr, dist, u)[source]

Gets point given reference point, direction vector and distance.

Parameters:
  • Rr (list) – Reference point.

  • dist (float) – Distance in angstroms.

  • u (list) – Direction vector.

Returns:

P – Final point.

Return type:

list

molSimplify.Scripts.geometry.kabsch(mol0, mol1)[source]

Aligns (translates and rotates) two molecules to minimize RMSD using the Kabsch algorithm.

Parameters:
  • mol0 (mol3D) – mol3D class instance of molecule to be aligned. Will be translated and rotated.

  • mol1 (mol3D) – mol3D class instance of reference molecule. Will be translated.

Returns:

  • mol0 (mol3D) – mol3D class instance of aligned molecule.

  • U (list) – Rotation matrix as list of lists.

  • d0 (list) – Translation vector for mol0.

  • d1 (list) – Translation vector for mol1.

molSimplify.Scripts.geometry.midpt(r1, r2)[source]

Vector midpoint.

Parameters:
  • r1 (list) – Vector 1.

  • r2 (list) – Vector 2.

Returns:

mid – Midpoint between vector 1 and 2.

Return type:

list

molSimplify.Scripts.geometry.norm(u)[source]

Get euclidean norm of vector.

Parameters:

u (list) – Vector of interest.

Returns:

norm – Norm of u.

Return type:

float

molSimplify.Scripts.geometry.normalize(u)[source]

Normalize a vector.

Parameters:

u (list) – Vector of interest.

Returns:

norm_vect – Normalized vector.

Return type:

list

molSimplify.Scripts.geometry.pmrotate(mol, Rp, D)[source]

Rotates molecule about Cartesian axes defined relative to given origin. Loops over PointRotateSph().

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be rotated.

  • Rp (list) – Cartesian origin.

  • D (list) – [theta-x, theta-y, theta-z] in DEGREES

Returns:

mol – mol3D class instance of rotated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.protate(mol, Rr, D)[source]

Translates molecule in spherical coordinates based on center of mass reference. Loops over PointTranslateSph().

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be translated.

  • Rr (list) – Origin of sphere.

  • D (list) – [final radial distance, change in polar phi, change in azimuthal theta] in RADIANS

Returns:

mol – mol3D class instance of translated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.protateref(mol, Rr, Rref, D)[source]

Translates molecule in spherical coordinates based on arbitrary reference. Loops over PointTranslateSph().

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be translated.

  • Rr (list) – Origin of sphere.

  • Rref (list) – Reference point in molecule

  • D (list) – [final radial distance, change in polar phi, change in azimuthal theta] in RADIANS

Returns:

mol – mol3D class instance of translated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.reflect_through_plane(mol, u, Rp)[source]

Reflects molecule about plane defined by its normal vector and a point on the plane. Loops over ReflectPlane().

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be reflected.

  • u (list) – Normal vector to plane.

  • Rp (list) – Reference point on plane.

Returns:

mol – mol3D class instance of reflected molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.rotateRef(mol, Ref, D)[source]

Rotates molecule about an arbitrary point Loops over PointRotateSph().

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be rotated.

  • Ref (list) – Reference point

  • D (list) – [theta-x, theta-y, theta-z] in RADIANS

Returns:

mol – mol3D class instance of rotated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.rotate_around_axis(mol, Rp, u, theta)[source]

Rotates molecule about axis defined by direction vector and point on axis. Loops over PointRotateAxis().

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be rotated.

  • Rp (list) – Reference point along axis.

  • u (list) – Direction vector of axis.

  • theta (float) – Angle of rotation in DEGREES.

Returns:

mol – mol3D class instance of rotated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.rotate_mat(mol, R)[source]

Rotates molecule using arbitrary rotation matrix. Loops over PointRotateMat().

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be rotated.

  • R (list) – List of lists containing rotation matrix.

Returns:

mol – mol3D class instance of rotated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.rotation_params(r0, r1, r2)[source]

Gets angle between three points (r10 and r21) and the normal vector to the plane containing three points.

Parameters:
  • r0 (list) – Coordinates for point 1.

  • r1 (list) – Coordinates for point 2.

  • r2 (list) – Coordinates for point 3.

Returns:

  • theta (float) – Angle in units of degrees.

  • u (list) – Normal vector.

molSimplify.Scripts.geometry.setPdistance(mol, Rr, Rp, bond)[source]

Translates molecule such that a given point in the molecule is at a given distance from a reference point. The molecule is moved along the axis given by the two points.

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be translated.

  • Rr (list) – Point in molecule to be aligned.

  • Rp (list) – Reference alignment point.

  • bond (float) – Final distance of aligned point to alignment point

Returns:

  • mol (mol3D) – mol3D class instance of translated molecule.

  • dxyz (np.array) – The translation vector.

molSimplify.Scripts.geometry.setPdistanceu(mol, Rr, Rp, bond, u)[source]

Translates molecule such that a given point in the molecule is at a given distance from a reference point. The molecule is moved along an arbitrary axis.

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be translated.

  • Rr (list) – Point in molecule to be aligned.

  • Rp (list) – Reference alignment point.

  • bond (float) – Final distance of aligned point to alignment point

  • u (list) – Direction vector of axis

Returns:

mol – mol3D class instance of translated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.setcmdistance(mol, Rp, bond)[source]

Translates molecule such that its center of mass is at a given distance from a reference point. The molecule is moved along the axis given by the two points.

Parameters:
  • mol (mol3D) – mol3D class instance of molecule to be translated.

  • Rp (list) – Reference alignment point.

  • bond (float) – Final distance of aligned point to alignment point

Returns:

mol – mol3D class instance of translated molecule.

Return type:

mol3D

molSimplify.Scripts.geometry.vecangle(r1, r2)[source]

Computes angle between two vectors.

Parameters:
  • r1 (list) – Vector 1.

  • r2 (list) – Vector 2.

Returns:

theta – Angle between two vectors in degrees.

Return type:

float

molSimplify.Scripts.geometry.vecdiff(r1, r2)[source]

Element-wise vector difference

Parameters:
  • r1 (list) – Vector 1.

  • r2 (list) – Vector 2.

Returns:

diff – Vector difference between points 1 and 2.

Return type:

list

molSimplify.Scripts.distgeom.CosRule(AB: float, BC: float, theta: float) float[source]

Applies the cosine rule to get the length of AC given lengths of AB, BC and angle ABC

Parameters:
  • AB (float) – Length of AB.

  • BC (float) – Length of BC.

  • theta (float) – theta Angle in degrees.

Returns:

AC – Length of AC.

Return type:

float

molSimplify.Scripts.distgeom.DistErr(x, *args)[source]

Computes distance error function for scipy optimization. Copied from E3 in pp. 311 of ref. [1]

Parameters:
  • x (np.array) – 1D array of coordinates to be optimized.

  • *args (dict) – Other parameters (refer to scipy.optimize docs)

Returns:

E – Objective function

Return type:

np.array

molSimplify.Scripts.distgeom.DistErrGrad(x, *args)[source]

Computes gradient of distance error function for scipy optimization. Copied from E3 in pp. 311 of ref. [1]

Parameters:
  • x (np.array) – 1D array of coordinates to be optimized.

  • *args (dict) – Other parameters (refer to scipy.optimize docs)

Returns:

g – Objective function gradient

Return type:

np.array

molSimplify.Scripts.distgeom.Get3Eigs(G, natoms)[source]

Gets 3 largest eigenvalues and corresponding eigenvectors of metric matrix

Parameters:
  • G (np.array) – Metric matrix.

  • natoms (int) – Number of atoms in the molecule.

Returns:

  • L (np.array) – Three largest eigenvalues

  • V (np.array) – Eigenvectors corresponding to largest eigenvalues.

molSimplify.Scripts.distgeom.GetBoundsMatrices(mol, natoms, catoms=[], shape=[], A=[])[source]

Generate distance bounds matrices. The basic idea is outlined in ref [1]. We first apply 1-2 (bond length) and 1-3 (bond angle) constraints, read from the FF-optimized initial conformer. Next, to bias the search towards coordinating conformers, approximate connection atom distance constraints based on topological distances are also included.

Parameters:
  • mol (mol3D) – mol3D class instance of molecule.

  • natoms (int) – Number of atoms in the molecule.

  • catoms (list, optional) – List of ligand connection atoms. Default is Empty.

  • shape (dict) – Dict containing angles.

  • A (list) – List of lists making a distance 2 connectivity matrix.

Returns:

  • LB (np.array) – Lower bound matrix.

  • UB (np.array) – Upper bound matrix.

molSimplify.Scripts.distgeom.GetCMDists(D, natoms)[source]

Get distances of each atom to center of mass given the distance matrix. Copied from ref [2], pp. 309.

Parameters:
  • D (np.array) – Distance matrix.

  • natoms (int) – Number of atoms in the molecule.

Returns:

  • D0 (np.array) – Vector of distances from center of mass.

  • status (bool) – Flag for successful search.

molSimplify.Scripts.distgeom.GetConf(mol, args, catoms=[])[source]

Uses distance geometry to get a random conformer.

Parameters:
  • mol (mol3D) – mol3D class instance for molecule of interest.

  • args (Namespace) – Namespace argument from inparse.

  • catoms (list, optional) – List of connection atoms used to generate additional constraints if specified (see GetBoundsMatrices()). Default is empty.

Returns:

Conf3D – mol3D class instance of new conformer.

Return type:

mol3D

molSimplify.Scripts.distgeom.GetMetricMatrix(D, D0, natoms)[source]

Get metric matrix from distance matrix and CM distances Copied from ref [2], pp. 306.

Parameters:
  • D (np.array) – Distance matrix.

  • D0 (np.array) – Vector of distances from center of mass.

  • natoms (int) – Number of atoms in the molecule.

Returns:

G – Metric matrix.

Return type:

np.array

molSimplify.Scripts.distgeom.Metrize(LB, UB, natoms, Full=False, seed=False)[source]

Metrization to select random in-range distances. Copied from ref [2], pp. 253-254. Scales O(N^3).

Parameters:
  • LB (np.array) – Lower bounds matrix.

  • UB (np.array) – Upper bounds matrix.

  • natoms (int) – Number of atoms in the molecule.

  • Full (bool, optional) – Flag for full metrization (scales O(N^5)). Default is False.

  • seed (bool, optional) – Flag for random number seed. Default is False.

Returns:

D – Distance matrix.

Return type:

np.array

molSimplify.Scripts.distgeom.SaveConf(X, mol, ffclean=True, catoms=[])[source]

Further cleans up with OB FF and saves to a new mol3D object. Note that distance geometry tends to produce puckered aromatic rings because of the lack of explicit impropers, see Riniker et al. JCIM (2015) 55, 2562-74 for details. Hence, a FF optimization (with connection atoms constrained) is recommended to clean up the structure.

Parameters:
  • x (np.array) – Array of coordinates.

  • mol (mol3D) – mol3D class instance of original molecule.

  • ffclean (bool, optional) – Flag for openbabel forcefield cleanup. Default is True.

  • catoms (list, optional) – List of connection atoms used to generate FF constraints if specified. Default is empty.

Returns:

conf3D – mol3D class instance of conformer.

Return type:

mol3D

molSimplify.Scripts.distgeom.Triangle(LB, UB, natoms)[source]

Triangle inequality bounds smoothing. Copied from ref [2], pp. 252-253. Scales O(N^3).

Parameters:
  • LB (np.array) – Lower bounds matrix.

  • UB (np.array) – Upper bounds matrix.

  • natoms (int) – Number of atoms in the molecule.

Returns:

  • LL (np.array) – Lower triangularized bound matrix

  • UL (np.array) – Upper triangularized bound matrix

molSimplify.Scripts.distgeom.findshape(args, master_ligand) Dict[source]

Determines the relative positioning of different ligating atoms

Parameters:
  • args (Namespace) – Namespace argument from inparse.

  • master_ligand (mol3D) – mol3D class instance of metal with the ligand.

Returns:

angles_dict – A dictionary of angles (in degrees) between catoms.

Return type:

dict

molSimplify.Scripts.distgeom.inverseCosRule(A, B, C) float[source]

Apply the cosine rule to find the angle ABC given points A,B, and C.

Parameters:
  • A (list) – Coordinates of A.

  • B (list) – Coordinates of B.

  • C (list) – Coordinates of C.

Returns:

theta – ABC angle theta in grees.

Return type:

float

molSimplify.Scripts.rmsd.centroid(X)[source]

Centroid is the mean position of all the points in all of the coordinate directions, from a vectorset X. https://en.wikipedia.org/wiki/Centroid C = sum(X)/len(X)

Parameters:

X (np.array) – (N,D) matrix, where N is points and D is dimension.

Returns:

C – centroid

Return type:

float

molSimplify.Scripts.rmsd.hungarian(A, B)[source]

Hungarian reordering. Assume A and B are coordinates for atoms of SAME type only.

Parameters:
  • A (np.array) – (N,D) matrix, where N is points and D is dimension. coordinates.

  • B (np.array) – (N,D) matrix, where N is points and D is dimension. coordinates.

Returns:

indices_b – Indices as a result of Hungarian analysis on distance matrix between atoms of 1st structure and trial structure

Return type:

np.array

molSimplify.Scripts.rmsd.kabsch(P, Q)[source]

Using the Kabsch algorithm with two sets of paired point P and Q, centered around the centroid. Each vector set is represented as an NxD matrix, where D is the dimension of the space. The algorithm works in three steps: 1. a centroid translation of P and Q (assumed done before this functioncall) 2. the computation of a covariance matrix C 3. computation of the optimal rotation matrix U For more info see http://en.wikipedia.org/wiki/Kabsch_algorithm

Parameters:
  • P (np.array) – (N,D) matrix, where N is points and D is dimension.

  • Q (np.array) – (N,D) matrix, where N is points and D is dimension.

Returns:

U – Rotation matrix (D,D)

Return type:

np.array

molSimplify.Scripts.rmsd.kabsch_rmsd(P, Q, translate=False)[source]

Rotate matrix P unto Q using Kabsch algorithm and calculate the RMSD.

Parameters:
  • P (np.array) – (N,D) matrix, where N is points and D is dimension.

  • Q (np.array) – (N,D) matrix, where N is points and D is dimension.

  • translate (bool, optional) – Use centroids to translate vector P and Q unto each other. Default is False.

Returns:

rmsd – root-mean squared deviation

Return type:

float

molSimplify.Scripts.rmsd.kabsch_rotate(P, Q)[source]

Rotate matrix P unto matrix Q using Kabsch algorithm.

Parameters:
  • P (np.array) – (N,D) matrix, where N is points and D is dimension.

  • Q (np.array) – (N,D) matrix, where N is points and D is dimension.

Returns:

P – (N,D) matrix, where N is points and D is dimension, rotated.

Return type:

np.array

molSimplify.Scripts.rmsd.makeQ(r1, r2, r3, r4=0)[source]

Make Q matrix involved in quaternion rotation

Parameters:
  • r1 (np.array) – Vector 1.

  • r2 (np.array) – Vector 2.

  • r3 (np.array) – Vector 3.

  • r4 (np.array, optional) – Vector 4. Default is 0.

Returns:

Q – Q matrix involved in quaternion rotation.

Return type:

np.array

molSimplify.Scripts.rmsd.makeW(r1, r2, r3, r4=0)[source]

Make W matrix involved in quaternion rotation

Parameters:
  • r1 (np.array) – Vector 1.

  • r2 (np.array) – Vector 2.

  • r3 (np.array) – Vector 3.

  • r4 (np.array, optional) – Vector 4. Default is 0.

Returns:

W – W matrix involved in quaternion rotation.

Return type:

np.array

molSimplify.Scripts.rmsd.quaternion_rmsd(P, Q) float[source]

Rotate matrix P unto Q and calculate the RMSD based on doi:10.1016/1049-9660(91)90036-O

Parameters:
  • P (np.array) – (N,D) matrix, where N is points and D is dimension.

  • Q (np.array) – (N,D) matrix, where N is points and D is dimension.

Returns:

rmsd – RMSD between P and Q.

Return type:

float

molSimplify.Scripts.rmsd.quaternion_rotate(X, Y)[source]

Calculate the rotation

Parameters:
  • X (array) – (N,D) matrix, where N is points and D is dimension.

  • Y (array) – (N,D) matrix, where N is points and D is dimension.

Returns:

rot – Rotation matrix (D,D)

Return type:

matrix

molSimplify.Scripts.rmsd.quaternion_transform(r)[source]

Get optimal rotation. Note: translation will be zero when the centroids of each molecule are the same.

Parameters:

r (np.array) – Array of vectors to transform.

molSimplify.Scripts.rmsd.reorder_distance(p_atoms, q_atoms, p_coord, q_coord)[source]

Re-orders the input atom list and xyz coordinates by atom type and then by distance of each atom from the centroid.

Parameters:
  • atoms (np.array) – (N,1) matrix, where N is points holding the atoms’ names

  • coord (np.array) – (N,D) matrix, where N is points and D is dimension

Returns:

  • atoms_reordered (np.array) – (N,1) matrix, where N is points holding the ordered atoms’ names

  • coords_reordered (np.array) – (N,D) matrix, where N is points and D is dimension (rows re-ordered)

molSimplify.Scripts.rmsd.reorder_hungarian(p_atoms, q_atoms, p_coord, q_coord)[source]

Re-orders the input atom list and xyz coordinates using the Hungarian method (using optimized column results)

Parameters:
  • p_atoms (np.array) – (N,1) matrix, where N is points holding the atoms’ names

  • p_atoms – (N,1) matrix, where N is points holding the atoms’ names

  • p_coord (np.array) – (N,D) matrix, where N is points and D is dimension

  • q_coord (np.array) – (N,D) matrix, where N is points and D is dimension

Returns:

view_reorder – (N,1) matrix, reordered indexes of atom alignment based on the coordinates of the atoms

Return type:

np.array

molSimplify.Scripts.rmsd.rigorous_rmsd(mol1, mol2, rotation: str = 'kabsch', reorder: str = 'hungarian') float[source]

Rigorous RMSD measurement

Parameters:
  • mol1 (mol3D) – mol3D instance of initial molecule.

  • mol2 (np.mol3D) – mol3D instance of final molecule.

  • rotation (str, optional) – Rotation method. Default is kabsch.

  • reorder (str, optional) – Reorder method. Default is hungarian.

Returns:

result_rmsd – Resulting RMSD from aligning and rotating.

Return type:

float

molSimplify.Scripts.rmsd.rmsd(V, W)[source]

Calculate Root-mean-square deviation from two sets of vectors V and W.

Parameters:
  • V (np.array) – (N,D) matrix, where N is points and D is dimension.

  • W (np.array) – (N,D) matrix, where N is points and D is dimension.

Returns:

rmsd – Root-mean-square deviation between the two vectors.

Return type:

float

molSimplify.Scripts.rmsd.rmsd_reorder_rotate(p_atoms, q_atoms, p_coord, q_coord, rotation='kabsch', reorder='hungarian')[source]

Reorder and rotate for RMSD.

Parameters:
  • p_atoms (np.array) – Atom symbol list.

  • q_atoms (np.array) – Atom symbol list.

  • p_coord (np.array) – List of coordinates for p_atoms.

  • q_atoms – List of coordinates for q_atoms.

  • rotation (str, optional) – Rotation method. Default is kabsch.

  • reorder (str, optional) – Reorder method. Default is hungarian.

Returns:

result_rmsd – Resulting RMSD from aligning and rotating.

Return type:

float

molSimplify.Scripts.rmsd.test_case()[source]

Cellbuilder Tools

molSimplify.Scripts.cellbuilder.align_payload_to_multi_site(payload, surface_coord_list, cand_list, bind_dist, debug=False)[source]
molSimplify.Scripts.cellbuilder.axes_angle_align(payload, cand_ind, align_ind, align_target, angle)[source]

This function rotates a given payload molecule such that the X-Y projection of the cord joining the two atoms in cand_ind and align_ind is aligned with the vector given in align_target.

Parameters:
  • payload (mol3D) – mol3D class that contains that target molecule

  • cand_ind (int) – index of atom in payload that is used as reference

  • align_ind (int) – index of atom in payload that define the cord to align

  • align_target (list of 3 float) – vector on the cell surface to align. Normally z=0

  • angle (float) – rotation angle

Returns:

new_payload – mol3D class, rotation of payload.

Return type:

mol3D

molSimplify.Scripts.cellbuilder.centered_align_coord(super_cell_vector)[source]
molSimplify.Scripts.cellbuilder.choose_best_site(avail_sites_dict, occupied_sites_dict, centroid, super_cell, super_cell_vector, weight=0.5, method='linear', debug=False)[source]
molSimplify.Scripts.cellbuilder.choose_nearest_neighbour(target_site, avail_sites_dict, occupied_sites_dict, super_cell, super_cell_vector, debug=False)[source]
molSimplify.Scripts.cellbuilder.combine_multi_aligned_payload_with_cell(super_cell, super_cell_vector, payload, cand_list, surface_coord_list, bind_dist, duplicate=False, control_angle=False, align_axis=False, align_ind=False, debug=False)[source]
molSimplify.Scripts.cellbuilder.concave_hull(points, alpha)[source]
molSimplify.Scripts.cellbuilder.cut_cell_to_index(unit_cell, cell_vector, miller_index)[source]
molSimplify.Scripts.cellbuilder.d_fix(unit_cell, cell_vector)[source]
molSimplify.Scripts.cellbuilder.force_field_relax_with_slab(super_cell, payload, cand_list, its)[source]
molSimplify.Scripts.cellbuilder.molecule_placement_supervisor(super_cell, super_cell_vector, target_molecule, method, target_atom_type, align_dist, surface_atom_type=False, control_angle=False, align_ind=False, align_axis=False, duplicate=False, number_of_placements=1, coverage=False, weighting_method='linear', weight=0.5, masklength=1, surface_atom_ind=False, debug=False)[source]
molSimplify.Scripts.cellbuilder.multialign_objective_function(payload, surface_coord_list, cand_list, bind_dist)[source]
molSimplify.Scripts.cellbuilder.slab_module_supervisor(args, rootdir)[source]
molSimplify.Scripts.cellbuilder.staggered2_align_coord(super_cell)[source]
molSimplify.Scripts.cellbuilder.surface_center(super_cell)[source]
molSimplify.Scripts.cellbuilder.tracked_merge(payload, super_cell)[source]
molSimplify.Scripts.cellbuilder.unit_to_super(unit_cell, cell_vector, duplication_vector)[source]
molSimplify.Scripts.cellbuilder_tools.apply_plane_to_point(point, n)[source]
molSimplify.Scripts.cellbuilder_tools.cell_ffopt(ff, mol, frozenats)[source]
molSimplify.Scripts.cellbuilder_tools.center_of_sym(list_of_points)[source]
molSimplify.Scripts.cellbuilder_tools.change_basis(mol, old_basis, new_basis)[source]
molSimplify.Scripts.cellbuilder_tools.check_top_layer_correct(super_cell, atom_type)[source]
molSimplify.Scripts.cellbuilder_tools.closest_torus_point(mol, dim)[source]
molSimplify.Scripts.cellbuilder_tools.distance_2d_torus(R1, R2, dim)[source]
molSimplify.Scripts.cellbuilder_tools.distance_2d_torus_next_only(R1, R2, dim)[source]
molSimplify.Scripts.cellbuilder_tools.distance_zw(r1, r2)[source]
molSimplify.Scripts.cellbuilder_tools.evaluate_basis_coefficients(coefficients, basis)[source]
molSimplify.Scripts.cellbuilder_tools.find_all_surface_atoms(super_cell, tol=0.01, type_of_atom=False)[source]
molSimplify.Scripts.cellbuilder_tools.find_extents(super_cell)[source]
molSimplify.Scripts.cellbuilder_tools.find_extents_cv(super_cell_vector)[source]
molSimplify.Scripts.cellbuilder_tools.fractionate_points_by_plane(super_cell, n, tol=1e-08)[source]
molSimplify.Scripts.cellbuilder_tools.freeze_bottom_n_layers(super_cell, n)[source]
molSimplify.Scripts.cellbuilder_tools.freeze_under_layer(super_cell)[source]
molSimplify.Scripts.cellbuilder_tools.get_basis_coefficients(point, basis)[source]
molSimplify.Scripts.cellbuilder_tools.import_from_cif(fst, return_extra_cif_info=False)[source]
molSimplify.Scripts.cellbuilder_tools.mdistance(r1, r2)[source]
molSimplify.Scripts.cellbuilder_tools.normalize_vector(v)[source]
molSimplify.Scripts.cellbuilder_tools.periodic_2d_distance(R1, R2, cell_vector)[source]
molSimplify.Scripts.cellbuilder_tools.periodic_mindist(mol, surf, dim)[source]
molSimplify.Scripts.cellbuilder_tools.periodic_selfdist(mol, dim)[source]
molSimplify.Scripts.cellbuilder_tools.point_in_box(point, box)[source]
molSimplify.Scripts.cellbuilder_tools.points_below_plane(point, n, refd)[source]
molSimplify.Scripts.cellbuilder_tools.shave__type(super_cell, dim, mode)[source]
molSimplify.Scripts.cellbuilder_tools.shave_surface_layer(super_cell, TOL=0.1)[source]
molSimplify.Scripts.cellbuilder_tools.shave_under_layer(super_cell)[source]
molSimplify.Scripts.cellbuilder_tools.threshold_basis(basis, threshold)[source]
molSimplify.Scripts.cellbuilder_tools.threshold_vector(v, threshold)[source]
molSimplify.Scripts.cellbuilder_tools.xgcd(b, n)[source]
molSimplify.Scripts.cellbuilder_tools.zero_x(super_cell)[source]
molSimplify.Scripts.cellbuilder_tools.zero_y(super_cell)[source]
molSimplify.Scripts.cellbuilder_tools.zero_z(super_cell)[source]
molSimplify.Scripts.cellbuilder_tools.zero_z_csm(super_cell)[source]

Input File Generation

molSimplify.Scripts.qcgen.gamgen(args, strfiles, method)[source]

Generate a single GAMESS input file.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

  • method (str) – Name of method to use, (e.g. B3LYP).

Returns:

jobdirs – List of job directory with GAMESS input file.

Return type:

list

molSimplify.Scripts.qcgen.mlpgen(args, strfiles, rootdir)[source]

Generate MOPAC input files.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

  • rootdir (str) – Path of the root directory.

Returns:

jobdirs – List of job directory with MOPAC input file.

Return type:

list

molSimplify.Scripts.qcgen.molcbasis(strfiles, basistyp)[source]

Generate MOLCAS basis keyword for a given mol3D.

Parameters:
  • strfiles (list) – List of XYZ files produced

  • basistyp (str) – The basis set.

Returns:

basis – String of basis specification.

Return type:

str

molSimplify.Scripts.qcgen.molcfrozens(strfiles)[source]

Determine MOLCAS CASSCF frozen orbitals for a given mol3D

Parameters:

strfiles (list) – List of XYZ files produced

Returns:

frozens – List of the frozen orbitals

Return type:

list

molSimplify.Scripts.qcgen.molcgen(args, strfiles, method)[source]

Generate a single MOLCAS input file.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

  • method (str) – Method to be used (e.g. B3LYP)

Returns:

jobdirs – List of job directory with MOLCAS input file.

Return type:

list

molSimplify.Scripts.qcgen.molcnactels(strfiles, oxnum)[source]

Determine MOLCAS CASSCF active electrons for a given mol3D.

Parameters:
  • strfiles (list) – List of XYZ files produced

  • oxnum (int) – Oxidation state.

Returns:

nactels – List of the active electrons

Return type:

list

molSimplify.Scripts.qcgen.molcras2s(strfiles)[source]

Determine MOLCAS CASSCF active space for a given mol3D.

Parameters:

strfiles (list) – List of XYZ files produced

Returns:

ras2s – List of the active spaces

Return type:

list

molSimplify.Scripts.qcgen.molcwrt(output, jobparams, xyzf, xyzind)[source]

Generate a single MOLCAS input file with custom parameters.

Parameters:
  • output (str) – Filename for writing the ORCA input.

  • jobparams (dict) – Dictionary of ORCA input parameters.

  • xyzf (str) – Name for XYZ file.

  • xyzind (int) – Index for xyz file in all generated xyz files

Returns:

jobdirs – List of job directory with ORCA input file.

Return type:

list

molSimplify.Scripts.qcgen.multigamgen(args, strfiles)[source]

Generate multiple GAMESS files, loops over methods.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

Returns:

jobdirs – List of job directories with GAMESS input files.

Return type:

list

molSimplify.Scripts.qcgen.multimolcgen(args, strfiles)[source]

Generate MOLCAS input files.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

Returns:

jobdirs – List of job directory with ORCA input files.

Return type:

list

molSimplify.Scripts.qcgen.multiogen(args, strfiles)[source]

Generate ORCA input files.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

Returns:

jobdirs – List of job directory with ORCA input files.

Return type:

list

molSimplify.Scripts.qcgen.multiqgen(args, strfiles)[source]

Generate multiple QChem input files at once.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

Returns:

jobdirs – List of job directories with QChem input files.

Return type:

list

molSimplify.Scripts.qcgen.multitcgen(args, strfiles)[source]

Generate multiple terachem input files at once.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

Returns:

jobdirs – List of job directories with terachem input files.

Return type:

list

molSimplify.Scripts.qcgen.ogen(args, strfiles, method)[source]

Generate a single ORCA input file.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

  • method (str) – Method to be used (e.g. B3LYP)

Returns:

jobdirs – List of job directory with ORCA input file.

Return type:

list

molSimplify.Scripts.qcgen.ogenwrt(output, jobparams, xyzf)[source]

Generate a single ORCA input file with custom parameters.

Parameters:
  • output (str) – Filename for writing the ORCA input.

  • jobparams (dict) – Dictionary of ORCA input parameters.

  • xyzf (str) – Name for XYZ file.

Returns:

jobdirs – List of job directory with ORCA input file.

Return type:

list

molSimplify.Scripts.qcgen.qgen(args, strfiles, method)[source]

Generate a single QChem input file.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

  • method (str) – Name of method to use, (e.g. B3LYP).

Returns:

jobdirs – List of job directory with QChem input file.

Return type:

list

molSimplify.Scripts.qcgen.tcgen(args, strfiles, method)[source]

Generate a single terachem input file.

Parameters:
  • args (Namespace) – Namespace of input arguments.

  • strfiles (list) – List of xyz files produced.

  • method (str) – Name of method to use, (e.g. B3LYP).

Returns:

jobdirs – List of job directory with terachem input file.

Return type:

list

molSimplify.Scripts.qcgen.xyz2gxyz(filename)[source]

Turn an XYZ file into a GAMESS XYZ file.

Parameters:

filename (str) – Filename of xyz file.

Returns:

gfilename – Filename of GAMESS xyz file.

Return type:

str

molSimplify.Scripts.periodic_QE.write_periodic_mol3d_to_qe(mol, cell_vector, path)[source]

molSimplify Argument Parser

molSimplify.Scripts.inparse.args_parser_retrain()[source]
molSimplify.Scripts.inparse.checkTrue(arg)[source]
molSimplify.Scripts.inparse.checkinput(args, calctype='base')[source]
molSimplify.Scripts.inparse.cleaninput(args)[source]
molSimplify.Scripts.inparse.deserialize_json(filein)[source]
molSimplify.Scripts.inparse.is_number(s)[source]
molSimplify.Scripts.inparse.parseCLI(args)[source]
molSimplify.Scripts.inparse.parseall(parser)[source]
molSimplify.Scripts.inparse.parseinputfile(args, inputfile_str=None)[source]
molSimplify.Scripts.inparse.parseinputs_advanced(*p)[source]
molSimplify.Scripts.inparse.parseinputs_autocorr(*p)[source]
molSimplify.Scripts.inparse.parseinputs_basic(*p)[source]
molSimplify.Scripts.inparse.parseinputs_binding(*p)[source]
molSimplify.Scripts.inparse.parseinputs_chainb(*p)[source]
molSimplify.Scripts.inparse.parseinputs_customcore(*p)[source]
molSimplify.Scripts.inparse.parseinputs_db(*p)[source]
molSimplify.Scripts.inparse.parseinputs_inputgen(*p)[source]
molSimplify.Scripts.inparse.parseinputs_ligdict(*p)[source]
molSimplify.Scripts.inparse.parseinputs_naming(*p)[source]
molSimplify.Scripts.inparse.parseinputs_postproc(*p)[source]
molSimplify.Scripts.inparse.parseinputs_random(*p)[source]
molSimplify.Scripts.inparse.parseinputs_slabgen(*p)[source]
molSimplify.Scripts.inparse.parseinputs_tsgen(*p)[source]