transformato.mutate

Description

Classes

class transformato.mutate.CommonCoreTransformation(cc1_indicies, cc2_indicies, ligand1_psf, ligand2_psf, tlc_cc1, tlc_cc2, charge_compensated_ligand2_psf, charge_mutation, bonded_terms_mutation)[source]
Parameters:
  • cc1_indicies (list)

  • cc2_indicies (list)

  • ligand1_psf (CharmmPsfFile)

  • ligand2_psf (CharmmPsfFile)

  • tlc_cc1 (str)

  • tlc_cc2 (str)

  • charge_compensated_ligand2_psf (CharmmPsfFile)

  • charge_mutation (bool)

  • bonded_terms_mutation (bool)

__init__(cc1_indicies, cc2_indicies, ligand1_psf, ligand2_psf, tlc_cc1, tlc_cc2, charge_compensated_ligand2_psf, charge_mutation, bonded_terms_mutation)[source]

Scale the bonded parameters inside the common core. :param cc1_indicies: indices of cc1 :type cc1_indicies: list :param cc2_indicies: indices of cc2 (in the same order as cc1) :type cc2_indicies: list :param ligand1_psf: :type ligand1_psf: pm.charmm.CharmmPsfFile (copy of only ligand) :param ligand2_psf: the target psf that is used to generate the new bonded parmaeters :type ligand2_psf: pm.charmm.CharmmPsfFile (copy of only ligand) :param tlc_cc1: three letter code of ligand in cc1 :type tlc_cc1: str :param tlc_cc2: three letter code of ligand in cc2 :type tlc_cc2: str

Parameters:
  • cc1_indicies (list)

  • cc2_indicies (list)

  • ligand1_psf (CharmmPsfFile)

  • ligand2_psf (CharmmPsfFile)

  • tlc_cc1 (str)

  • tlc_cc2 (str)

  • charge_compensated_ligand2_psf (CharmmPsfFile)

  • charge_mutation (bool)

  • bonded_terms_mutation (bool)

__weakref__

list of weak references to the object

_get_atom_mapping()[source]

_get_atom_mapping – match the atom names of the common cores

Returns:

matched common core atom names

Return type:

[dict]

_mutate_atoms(psf, lambda_value)[source]

mutate atom types.

Raises:

RuntimeError – if common core atoms can not be matched

Parameters:
  • psf (CharmmPsfFile)

  • lambda_value (float)

mutate(psf, lambda_value)[source]

Mutates the bonded parameters of cc1 to cc2. :param psf: psf that gets mutated :type psf: pm.charmm.CharmmPsfFile :param lambda_value: lambda_value :type lambda_value: float

Parameters:
  • psf (CharmmPsfFile)

  • lambda_value (float)

class transformato.mutate.DummyRegion(mol_name: str, match_termin_real_and_dummy_atoms: dict, connected_dummy_regions: list, tlc: str, lj_default: list)[source]
Parameters:
  • mol_name (str)

  • match_termin_real_and_dummy_atoms (dict)

  • connected_dummy_regions (list)

  • tlc (str)

  • lj_default (list)

__eq__(other)

Return self==value.

__hash__ = None
__init__(mol_name, match_termin_real_and_dummy_atoms, connected_dummy_regions, tlc, lj_default)
Parameters:
  • mol_name (str)

  • match_termin_real_and_dummy_atoms (dict)

  • connected_dummy_regions (list)

  • tlc (str)

  • lj_default (list)

Return type:

None

__repr__()

Return repr(self).

__weakref__

list of weak references to the object

class transformato.mutate.Mutation(atoms_to_be_mutated, dummy_region)[source]
Parameters:
  • atoms_to_be_mutated (list)

  • dummy_region (DummyRegion)

__init__(atoms_to_be_mutated, dummy_region)[source]
Parameters:
  • atoms_to_be_mutated (list)

  • dummy_region (DummyRegion)

__weakref__

list of weak references to the object

_compensate_charge(psf, total_charge, offset)[source]

_compensate_charge This function compensates the charge changes of a dummy region on the terminal real atom that connects the specific dummy group to the real region.

Parameters:
  • psf (pm.charmm.CharmmPsfFile) – [description]

  • total_charge (int) – [description]

  • offset (int) – [description]

Raises:

RuntimeError – [description]

_mutate_vdw(psf, lambda_value, vdw_atom_idx, offset, to_default)[source]

This is used to scale the LJ parameters of the DDD and DDX atoms to zero in phase II and III

Parameters:
  • psf (CharmmPsfFile)

  • lambda_value (float)

  • vdw_atom_idx (List[int])

  • offset (int)

  • to_default (bool)

static _scale_epsilon_and_rmin(atom, lambda_value, psf, tlc)[source]

This scales the LJ interactions (epsilon and rmin) from non-interacting DDD atom (no charge) to ‘real’ dummy atom (no LJ!), typically this is performed in one step, but to be sure we offer scalling possibility here as well

mutate(psf, lambda_value_electrostatic=1.0, lambda_value_vdw=1.0, vdw_atom_idx=[], steric_mutation_to_default=False)[source]

Performs the mutation

Parameters:
  • psf (CharmmPsfFile)

  • lambda_value_electrostatic (float)

  • lambda_value_vdw (float)

  • vdw_atom_idx (List[int])

  • steric_mutation_to_default (bool)

class transformato.mutate.MutationDefinition(atoms_to_be_mutated: List[int], common_core: List[int], dummy_region: transformato.mutate.DummyRegion, vdw_atom_idx: List[int] = <factory>, steric_mutation_to_default: bool = False)[source]
Parameters:
  • atoms_to_be_mutated (List[int])

  • common_core (List[int])

  • dummy_region (DummyRegion)

  • vdw_atom_idx (List[int])

  • steric_mutation_to_default (bool)

__eq__(other)

Return self==value.

__hash__ = None
__init__(atoms_to_be_mutated, common_core, dummy_region, vdw_atom_idx=<factory>, steric_mutation_to_default=False)
Parameters:
  • atoms_to_be_mutated (List[int])

  • common_core (List[int])

  • dummy_region (DummyRegion)

  • vdw_atom_idx (List[int])

  • steric_mutation_to_default (bool)

Return type:

None

__repr__()

Return repr(self).

__weakref__

list of weak references to the object

class transformato.mutate.ProposeMutationRoute(s1, s2=None)[source]
Parameters:
__init__(s1, s2=None)[source]

A class that proposes the mutation route between two molecules with a common core (same atom types) based on two mols and generates the mutation objects to perform the mutation on the psf objects. :param mol1: :type mol1: Chem.Mol :param mol2: :type mol2: Chem.Mol

Parameters:
__weakref__

list of weak references to the object

static _calculate_order_of_LJ_mutations(connected_dummy_regions, match_terminal_atoms, G, cyclecheck=True, ordercycles=True, exclude_Hs=False)[source]

bfs/djikstra-algorithm applied to calculate the ordere for turning of the LJ interactions of the heavy atoms

most functions for theses options are imported from the helper_functions file cyclecheck: updates weights according to cycle participation (should always be set to True) ordercheck: if there is no possibility to decide between two nodes - i.e. the weight would be the exactly the same - weight updating according to preferential removal decides that the node in which neighbourhood nodes already have been removed is removed next exclude_Hs: if True, hydrogens are removed before the mutation algorithm is applied - necessary for usual Transformato workflow

Parameters:
  • connected_dummy_regions (list)

  • match_terminal_atoms (dict)

  • G (Graph)

Return type:

list

_check_for_lp(odered_connected_dummy_regions_cc_with_lp, psf, tlc, name)[source]

With the help of parmed this function will look in the ordered_connected_dummy_regions list if there is a atom which has lonepairs. It will check wheather the lp belongs to the common core or to the dummy region and assign it into the sorted list accordingly.

Parameters:
  • odered_connected_dummy_regions_cc_with_lp (list)

  • psf (CharmmPsfFile)

  • tlc (str)

  • name (str)

Return type:

list

_find_mcs(mol1_name, mol2_name, iterate_over_matches=False, max_matches=10)[source]

A class that proposes the mutation route between two molecules with a common core (same atom types) based on two mols and generates the mutation objects to perform the mutation on the psf objects. :param mol1_name: :type mol1_name: str :param mol2_name: :type mol2_name: str

Parameters:
  • mol1_name (str)

  • mol2_name (str)

  • iterate_over_matches (bool)

  • max_matches (int)

static _find_terminal_atom(cc_idx, mol)[source]

Find atoms that connect the molecule to the common core.

Parameters:
  • cc_idx (list) – common core index atoms

  • mol ([type]) – rdkit mol object

Return type:

Tuple[list, list]

_get_common_core(name)[source]

Helper Function - should not be called directly. Returns the common core.

Parameters:

name (str)

Return type:

list

static _match_terminal_real_and_dummy_atoms(mol, real_atoms_cc, dummy_atoms_cc)[source]

Matches the terminal real and dummy atoms and returns a dict with real atom idx as key and a set of dummy atoms that connect to this real atom as a set

Parameters:
  • mol ([Chem.Mol]) – The mol object with the real and dummy atoms

  • real_atoms_cc (list) – list of real atom idx

  • dummy_atoms_cc (list) – list of dummy atom idx

Returns:

[description]

Return type:

[type]

_match_terminal_real_and_dummy_atoms_for_mol1()[source]

Matches the terminal real and dummy atoms and returns a dict with real atom idx as key and a set of dummy atoms that connect to this real atom as a set

_match_terminal_real_and_dummy_atoms_for_mol2()[source]

Matches the terminal real and dummy atoms and returns a dict with real atom idx as key and a set of dummy atoms that connect to this real atom as a set

Return type:

dict

_mutate_to_common_core(dummy_region, cc_idx, mol_name)[source]

Helper function - do not call directly. Generates the mutation route to the common fore for mol.

Parameters:
  • dummy_region (DummyRegion)

  • cc_idx (list)

  • mol_name (str)

Return type:

dict

_show_common_core(mol, highlight, show_atom_type, internal)[source]

Helper function - do not call directly. Show common core.

Parameters:
  • highlight (list)

  • show_atom_type (bool)

  • internal (bool)

_transform_common_core()[source]

Common Core 1 is transformed to Common core 2. Bonded parameters and charges are adjusted.

Return type:

list

add_idx_to_common_core_of_mol1(idx_list)[source]

Adds a list of atoms to the common core of molecule 1

Caution

Be aware of the ordering! Atom idx need to be added to match the ordering of the atom idx of common core 2

Parameters:

idx_list (list) – Array of atom idxs to add

add_idx_to_common_core_of_mol2(idx_list)[source]

Adds a list of atoms to the common core of molecule 1

Caution

Be aware of the ordering! Atom idx need to be added to match the ordering of the atom idx of common core 2

Parameters:

idx_list (list) – Array of atom idxs to add

finish_common_core(connected_dummy_regions_cc1=[], connected_dummy_regions_cc2=[], odered_connected_dummy_regions_cc1=[], odered_connected_dummy_regions_cc2=[])[source]

The dummy region is created and the final atoms connected to the CC are collected. It is possible to define a dummy region on its own or to change the ordering how the lj parameters of the heavy atoms in the dummy region are turned off ——— connected_dummy_regions_cc1: list = [] connected_dummy_regions_cc2: list = [] odered_connected_dummy_regions_cc1: list = [] odered_connected_dummy_regions_cc2: list = []

Parameters:
  • connected_dummy_regions_cc1 (list)

  • connected_dummy_regions_cc2 (list)

  • odered_connected_dummy_regions_cc1 (list)

  • odered_connected_dummy_regions_cc2 (list)

generate_mutations_to_common_core_for_mol1()[source]

Generates the mutation route to the common fore for mol1.

mutations: list

list of mutations

Return type:

dict

generate_mutations_to_common_core_for_mol2()[source]

Generates the mutation route to the common fore for mol2. :returns: mutations – list of mutations :rtype: list

Return type:

dict

get_common_core_idx_mol1()[source]

Returns the common core of mol1.

Return type:

list

get_common_core_idx_mol2()[source]

Returns the common core of mol2.

Return type:

list

get_idx_of_all_atoms(mol1_name)[source]

Iterates over all atoms of the molecule and saves them as a list

mol1_name: str

Parameters:

mol1_name (str)

propose_common_core()[source]

Searches for the common core using the rdkit module, in case of asfe only a list of atoms of the ligand is created

show_common_core_on_mol1(show_atom_types=False)[source]

Shows common core on mol1

Parameters:

show_atom_types (bool)

show_common_core_on_mol2(show_atom_types=False)[source]

Shows common core on mol2

Parameters:

show_atom_types (bool)

Functions

mutate.perform_mutations(i, mutation_list, list_of_heavy_atoms_to_be_mutated=[], nr_of_mutation_steps_charge=5, nr_of_mutation_steps_lj_of_hydrogens=1, nr_of_mutation_steps_lj_of_heavy_atoms=1, nr_of_mutation_steps_cc=5, endstate_correction=False)

Performs the mutations necessary to mutate the physical endstate to the defined common core.

Parameters:
  • configuration (dict) – A configuration dictionary.

  • i ([type]) – IntermediateState instance

  • mutation_list (list) – list of mutation objects

  • list_of_heavy_atoms_to_be_mutated (list, optional) – A list of atom indices that define the order in which the vdw parameters of the heavy atoms are turned off. Defaults to [].

  • nr_of_mutation_steps_charge (int, optional) – Nr of steps to turne of the charges. Defaults to 5.

  • nr_of_mutation_steps_lj_of_hydrogens (int, optional) – Nr of steps to turne of lj of hydrogens. Only needed for systems with many hydrogens in dummy region

  • nr_of_mutation_steps_lj_of_heavy_atoms (int, optional) – Nr of steps to turne of the lj of heavy atoms

  • nr_of_mutation_steps_cc (int, optional) – Nr of steps to interpolate between the common core parameters. Defaults to 5.

  • endstate_correction (bool)

Returns:

list of directories with the parameter and topology files

Return type:

list