gaudi.genes¶
These are the built-in genes in GAUDI. You can also build your own, but these are ready to use.
Molecule gene¶
This gene implements a wrapper around Chimera.molecule objects to expand its original features, such as appending new molecules.
This allows to build new structures with a couple of building blocks as a starting
point, as well as keeping several ligands as different potential solutions to the
essay (think about multi-molecule alternative docking). The user can also request
more gaudi.genes.molecule
instances for the genome of the individual,
resulting in a competitive multi-docking essay.
To handle all this diversity, each construction is cached the first time is built.
This class is a dependency of most of the other genes (and even objectives), so it will be requested almost always.
-
class
gaudi.genes.molecule.
Compound
(molecule=None, origin=None, seed=0.0, **kwargs)¶ Bases:
object
Wraps chimera.Molecule instances and allows to perform copies, appending new fragments, free placement and extended attributes.
Parameters: - molecule (chimera.Molecule or str, optional) –
The chimera.Molecule object to wrap, or
’dummy’ (for a empty molecule), or
The path to a mol2 file that will be parsed by Chimera to return a valid chimera.Molecule object.
- origin (3-tuple of float, optional) – Coordinates to the place where the molecule should be placed
- seed (float, optional) – Random seed, used by the vertex chooser on appending.
- optional (kwargs,) – Additional parameters that should be injected as attributes
-
mol
¶ Type: chimera.Molecule
-
donor
¶ If self were to be bonded to another Compound, this atom would be the one involved in the bond. By default, first element in chimera.Molecule.atoms
Type: chimera.Atom
-
acceptor
¶ If another Compound wanted to be bonded to self, this atom would be the one involved in the bond. By default, last element in chimera.Molecule.atoms
Type: chimera.Atom
-
origin
¶ Default location of mol in the 3D canvas.
Type: 3-tuple of float
-
seed
¶ Randomness seed for vertex computation.
Type: float
-
rotatable_bonds
¶ Bonds that can be torsioned
Type: list of chimera.Bond
-
nonrotatable
¶ Bonds that, although possible, should not be torsiond. Ie, fixed bonds.
Type: list of chimera.Bond
-
built_atoms
¶ Memo of already built_atoms
Type: list of chimera.Atom
Notes
Todo
Instead of a molecule parameter overload, think of using equivalent classmethods.
-
add_dummy_atom
(where, name='dum', element=None, residue=None, bonded_to=None, serial=None)¶ Adds a placeholder atom at the coordinates specified by where
Parameters: - where (chimera.Atom or 3-tuple of float) – Coordinates of target location. A chimera.Atom can be supplied, in which case its coordinates will be used (via .coord())
- name (str, optional) – Name for the new atom
- element (chimera.Element, optional) – Element of the new atom
- residue (chimera.Residue, optional) – Residue that will incorporate the new atom
- bonded_to (chimera.Atom, optional) – Atom that will form a bond with new atom
- serial (int) – Serial number that will be assigned to atom
-
add_hydrogens
()¶ Add missing hydrogens to current molecule
-
append
(molecule)¶ Wrapper around attach to add a new molecule to self, using self.acceptor as bonding atom.
Parameters: molecule (Compound) –
-
apply_pdbfix
(pH=7.0)¶ Run PDBFixer and replace original molecule with new one
-
attach
(molecule, acceptor, donor)¶ Call join to bond molecule to self.mol and updates attributes.
Parameters: - molecule (Compound) – The molecule that will be attached to self
- acceptor (chimera.Atom) – Atom of self that will participate in the new bond
- donor (chimera.Atom) – Atom of molecule that will participate in the new bond
Notes
Note
After joining the two molecules together, we have to update the attributes of self to match the new molecular reality. For example, the atom participating in the bond will not be available for new bonds (we are forcing linear joining for now), so the new donor will be inherited from molecule, before deleting the object.
-
destroy
()¶ Removes mol from canvas, deletes it and then, deletes itself
-
join
(molecule, acceptor, donor, newres=False)¶ Take a molecule and bond it to self.mol, copying the atoms in the process so they’re contained in the same chimera.Molecule object.
Parameters: - molecule (Compound) – The molecule that will be attached to self
- acceptor (chimera.Atom) – Atom of self that will participate in the new bond
- donor (chimera.Atom) – Atom of molecule that will participate in the new bond
- newres (bool) – If True, don’t reuse acceptor.residue for the new molecule, and create a new blank one instead.
Returns: built_atoms – Maps original atoms in molecules to their new counterparts in self.mol.
Return type: dict
Notes
Note
Chimera does not allow bonds between different chimera.Molecule objects, so firstly, we have to copy the atoms of
molecule
toself.mol
and, only then, make the joining bond.It traverses the atoms of
molecule
and adds a copy of each of them toself.mol
usingchimera.molEdit.addAtom
in the same spot of space. All the bonds are preserved and, finally, bond the two molecules.The algorithm starts by adding the bonding atom of
molecule
(donor
), to thesprouts
list. Then, the loop starts:while sprouts contains atoms: sprout = sprouts.pop(0) copy sprout to self.mol for each neighbor of sprout copy neighbor to self.mol if neighbor itself has more than one neighbor (ie, sprout) add neighbor to sprouts
Along the way, we have to take care of already processed sprouts, so we don’t repeat ourselves. That’s what the built_atoms dict is for.
Also, instead of letting addAtom guess new serial numbers, we calculate them beforehand by computing the highest serial number in
self.mol
prior to the additions and then incremeting one by one on a per-element basis.Todo
This code is UGLY. Find a better way!
-
parse_attr
()¶
-
place
(where, anchor=None)¶ Convenience wrapper around translate, supplying default
Parameters: - where (3-tuple of float, or chimera.Atom) – Coordinates of destination. If chimera.Atom, use supplied coord()
- anchor (chimera.Atom) – The atom that will guide the translation.
Notes
Note
Anchor atoms are called that way in the API because I picture them as the one we pick with our hands to drag the molecule to the desired place.
-
place_for_bonding
(target, anchor=None)¶ Translate self.mol to a covalent distance of target atom, with an adequate orientation.
Parameters: - target (chimera.Atom) – The atom we are willing to bond later on.
- anchor (chimera.Atom, optional) –
-
prepend
(molecule)¶ Wrapper around attach to add a new molecule to self, using self.donor as bonding atom.
Parameters: molecule (Compound) –
-
set_vdw_radii
(vdw_radii)¶
-
update_attr
(d)¶
- molecule (chimera.Molecule or str, optional) –
-
class
gaudi.genes.molecule.
Molecule
(path=None, symmetry=None, hydrogens=False, pdbfix=False, vdw_radii=None, **kwargs)¶ Bases:
gaudi.genes.GeneProvider
Interface around the
gaudi.genes.molecule.Compound
to handle the GAUDI protocol and caching features.Parameters: - path (str, optional) – Path to a molecule file or a directory containing dirs of molecule files.
- symmetry (str, optional) – If path is a directory, list of pairs of directories whose chosen mocule must be the same, thus enabling symmetry.
- hydrogens (bool, optional) – Add hydrogens to Molecule (True) or not (False).
- pdbfix (bool, optional) – Only for testing and debugging. Better run pdbfixer prior to GAUDI. Fix potential issues that may cause troubles with OpenMM forcefields.
- vdw_radii (dict {str: float} , optional) –
Set a specific vdw_radius for a particular element (instead of standard Chimera VdW table). It can be useful in particular cases together with a contacts objective. Example of use in the .yaml file: vdw_radii: {
Fe: 2.00, Cu: 2.16}Defaults to None
-
allele
¶ Paths to every fragment that composes a given Compound. It will consist of a single value tuple if there’s no dynamic building involved; ie, a mol2 or pdb file as is.
Type: tuple of str
-
_CATALOG
¶ Class attribute (shared among all Molecule instances) that holds all the possible molecules GAUDI can build given current path.
If path is a single molecule file, that’s the only possibility, but if it’s set to a directory, the engine can potentially build all the combinations of molecule blocks found in those subdirectories.
Normally, it is accessed via the catalog property.
Type: dict
Notes
Use of `_cache`
Molecule class uses _cache to store already built molecules. Its entry in the _cache directory is a boltons.cacheutils.LRU cache (least recently used) set to a maximum size of 300 entries.
Todo
The LRU cache size should be proportional to job size, depending on the population size and number of generations, but also taking available memory into account (?).
-
SUPPORTED_FILETYPES
= ('mol2', 'pdb')¶
-
build
(key, where=None)¶ Builds a Compound following the recipe contained in key through Compound.append methods.
Parameters: key (tuple of str) – Paths to the molecule blocks that comprise the final molecule. A single molecule is just a one-block recipe. Returns: The final molecule result of the sequential appending. Return type: Compound
-
classmethod
clear_cache
()¶
-
compound
¶ Get expressed allele on-demand (read-only attribute)
-
express
()¶ Adds Chimera molecule object to the viewer canvas.
It also converts pseudobonds (used by Chimera to depict coordinated ligands to metals) to regular bonds.
-
find_atom
(serial)¶
-
find_atoms
(serial, only_one=False)¶
-
find_residue
(position)¶
-
find_residues
(position, only_one=False)¶
-
get
(key)¶ Looks for the compound corresponding to key in _cache. If found, return it. Else, build it on demand, store it on cache and return it.
Parameters: key (str) – Path (or combination of) to the requested molecule. It should be extracted from catalog. Returns: The result of building the requested molecule. Return type: gaudi.genes.molecule.Compound
-
mate
(mate)¶ Todo
Allow mating while preserving symmetry
-
mutate
(indpb)¶ VERY primitive. It only gets another compound.
-
unexpress
()¶ Removes the Chimera molecule from the viewer canvas (without deleting the object).
-
write
(path=None, name=None, absolute=None, combined_with=None, filetype='mol2')¶ Writes full mol2 to disk.
Todo
It’d be preferable to get a string instead of a file
-
xyz
(transformed=True)¶
-
gaudi.genes.molecule.
enable
(**kwargs)¶
Mutamers gene¶
This modules allows to explore side chains flexibility in proteins, as well as mutation.
It needs that at least a gaudi.genes.rotamers.molecule.Molecule
has been
requested in the input file. Residues of those are referenced in the residues argument.
It also allows mutations in the selected residues. However, the resulting structure keeps the same backbone, which may not be representative of the in-vivo behaviour. Use with caution.
-
class
gaudi.genes.mutamers.
Mutamers
(residues=None, library='Dunbrack', avoid_replacement=False, mutations=[], ligation=False, hydrogens=False, **kwargs)¶ Bases:
gaudi.genes.GeneProvider
Mutamers class
Parameters: - residues (list of str) –
Residues that can mutate. This has to be in the form:
[ Protein/233, Protein/109 ]where the first element (before slash) is the gaudi.genes.molecule name and the second element (after slash) is the residue position number in that molecule.
This list of str is later parsed to the proper chimera.Residue objects
- library ({'Dunbrack', 'Dynameomics'}) – The rotamer library to use.
- mutations (list of str, required) – Aminoacids (in 3-letter codes) residues can mutate to.
- ligation (bool, optional) – If True, all residues will mutate to the same type of aminoacid.
- hydrogens (bool, optional) – If True, add hydrogens to replacing residues (buggy)
-
allele
¶ For i residues, it contains i tuples with two values each: residue type and a float within [0, 1), which will be used to pick one of the rotamers for that residue type.
Type: list of 2-tuple (str, float)
-
static
add_hydrogens_to_isolated_rotamer
(rotamers)¶
-
choice
(l)¶ Overrides
random.choice
with custom one so we can reuse a previously obtained random number. This helps dealing with theligation
parameter, which forces all the requested residues to mutate to the same type
-
express
()¶ Compile the gene to an evaluable object.
-
get_rotamers
(mol, pos, restype)¶ Gets the requested rotamers out of cache and if not found, creates the library and stores it in the cache.
Parameters: - mol (str) – gaudi.genes.molecule name that contains the residue
- pos – Residue position in mol
- restype – Get rotamers of selected position with this type of residue. It does not need to be the original type, so this allows mutations
Returns: Return type: List of rotamers returned by
Rotamers.getRotamers
.
-
mate
(mate)¶ Perform a crossover with another gene of the same kind.
-
mutate
(indpb)¶ Perform a mutation on the gene.
-
unexpress
()¶ Revert expression.
-
static
update_rotamer_coords
(residue, rotamer)¶
- residues (list of str) –
-
gaudi.genes.mutamers.
enable
(**kwargs)¶
NormalModes gene¶
This module allows to explore molecular folding through normal modes analysis.
It works by calculating normal modes for the input molecule and moving along a combination of normal modes.
It needs at least a gaudi.genes.rotamers.molecule.Molecule
.
-
class
gaudi.genes.normalmodes.
NormalModes
(method='prody', target=None, modes=None, n_samples=10000, rmsd=1.0, group_by=None, group_lambda=None, path=None, write_modes=False, **kwargs)¶ Bases:
gaudi.genes.GeneProvider
NormalModes class
Parameters: - method (str, optional, default=prody) – Either: - prody : calculate normal modes using prody algorithms - gaussian : read normal modes from a gaussian output file
- target (str) – Name of the Gene containing the actual molecule
- modes (list, optional, default=range(12)) – Modes to be used to move the molecule
- group_by (str or callable, optional, default=None) – Available str names: residues, mass.
This is, consider only pseudoatoms that group a whole
residue, groups of contiguous atoms that amount for certain
mass, or only alpha carbons. If residues or mass, the
group_lambda
parameter can customize the behaviour. - group_lambda (int, optional) – Either: number of residues per group (default=7), or number of groups with same mass (default=100).
- path (str) – Gaussian or prody modes output path. Required if
method
isgaussian
. - write_modes (bool, optional) – write a
molecule_modes.nmd
file with the ProDy modes - n_samples (int, optional, default=10000) – number of conformations to generate
- rmsd (float, optional, default=1.0) – RMSD (in angstrom) that the conformations will have with respect to the initial conformation. In some cases, it can be slightly higher than the requested threshold (e.g. 1.07A instead of 1A)
-
allele
¶ Randomly picked coordinates from NORMAL_MODE_SAMPLES
Type: slice of prody.ensemble
-
NORMAL_MODES
¶ normal modes calculated for the molecule or readed from the gaussian frequencies output file stored in a prody modes class (ANM or RTB)
Type: prody.modes
-
NORMAL_MODE_SAMPLES
¶ configurations applying modes to molecule
Type: prody.ensemble
-
_original_coords
¶ Parent coordinates
Type: numpy.array
-
_chimera2prody
¶ _chimera2prody[chimera_index] = prody_index
Type: dict
-
NORMAL_MODES
-
NORMAL_MODES_SAMPLES
¶
-
calculate_prody_normal_modes
()¶ calculate normal modes, creates a diccionary between chimera and prody indices and calculate n_confs number of configurations using this modes
-
express
()¶ Apply new coords as provided by current normal mode
-
mate
(mate)¶ Todo
Combine coords between two samples in NORMAL_MODES_SAMPLES? Or two samples between diferent NORMAL_MODES_SAMPLES? Or combine samples between two NORMAL_MODES_SAMPLES?
For now : pass
-
molecule
¶
-
mutate
(indpb)¶ (mutate to/get) another SAMPLE with probability = indpb
-
read_gaussian_normal_modes
()¶ read normal modes, creates a diccionary between chimera and prody indices and calculate n_confs number of configurations using this modes
-
read_prody_normal_modes
()¶
-
unexpress
()¶ Undo coordinates change
-
gaudi.genes.normalmodes.
alg3
(moldy, max_bonds=3, **kwargs)¶ TESTS PENDING!
- Coarse Grain Algorithm 3: Graph algorithm.
- New group when a vertice: have more than n,
- have 0 edges new chain
Parameters: - moldy (prody.AtomGroup) –
- n (int, optional, default=2) – maximum bonds number
Returns: moldy – New Betas added
Return type: prody.AtomGroup
-
gaudi.genes.normalmodes.
chimeracoords2numpy
(molecule)¶ Parameters: molecule (chimera.molecule) – Returns: Return type: numpy.array with molecule.atoms coordinates
-
gaudi.genes.normalmodes.
chunker
(end, n)¶ divide end integers in closed groups of n
-
gaudi.genes.normalmodes.
convert_chimera_molecule_to_prody
(molecule)¶ Function that transforms a chimera molecule into a prody atom group
Parameters: molecule (chimera.Molecule) – Returns: - prody_molecule (prody.AtomGroup())
- chimera2prody (dict) – dictionary: chimera2prody[chimera_atom.coordIndex] = i-thm element prody getCoords() array
-
gaudi.genes.normalmodes.
enable
(**kwargs)¶
-
gaudi.genes.normalmodes.
gaussian_modes
(path)¶ Read the modes Create a prody.modes instance
Parameters: path (str) – gaussian frequencies output path Returns: modes Return type: ProDy modes ANM or RTB
-
gaudi.genes.normalmodes.
group_by_mass
(molecule, n=100)¶ Coarse Grain Algorithm 2: groups per mass percentage
Parameters: - molecule (prody.AtomGroup) –
- n (int, optional, default=100) – Intended number of groups. The mass of the system will be divided by this number, and each group will have the corresponding proportional mass. However, the final number of groups can be slightly different.
Returns: molecule – New Betas added
Return type: prody.AtomGroup
-
gaudi.genes.normalmodes.
group_by_residues
(molecule, n=7)¶ Coarse Grain Algorithm 1: groups per residues
Parameters: - molecule (prody.AtomGroup) –
- n (int, optional, default=7) – number of residues per group
Returns: molecule – New betas added
Return type: prody.AtomGroup
-
gaudi.genes.normalmodes.
prody_modes
(molecule, max_modes, algorithm=None, **options)¶ Parameters: - molecule (prody.AtomGroup) –
- nax_modes (int) – number of modes to calculate
- algorithm (callable, optional, default=None) – coarseGrain(prm) wich make molecule.select().setBetas(i) where i is the index Coarse Grain group Where prm is prody AtomGroup
- options (dict, optional) – Parameters for algorithm callable
Returns: modes
Return type: ProDy modes ANM or RTB
Rotamers gene¶
This modules allows to explore side chains flexibility in proteins, as well as mutation.
It needs that at least a gaudi.genes.rotamers.molecule.Molecule
has been
requested in the input file. Residues of those are referenced in the residues argument.
It also allows mutations in the selected residues. However, the resulting structure keeps the same backbone, which may not be representative of the in-vivo behaviour. Use with caution.
-
class
gaudi.genes.rotamers.
Rotamers
(residues=None, library='Dunbrack', with_original=True, **kwargs)¶ Bases:
gaudi.genes.GeneProvider
Rotamers class
Parameters: - residues (list of str) –
Residues that should be analyzed. This has to be in the form:
[ Protein/233, Protein/109 ]where the first element (before slash) is the gaudi.genes.molecule name and the second element (after slash) is the residue position number in that molecule.
This list of str is later parsed to the proper chimera.Residue objects
- library ({'Dunbrack', 'Dynameomics'}) – The rotamer library to use.
- with_original (bool, defaults to True) – Whether to include the original set of chi angles as part of the rotamer library.
-
allele
¶ For i residues, it contains i floats within [0, 1), that will point to the selected rotamer torsions for each residue.
Type: list of float
-
static
all_chis
(residue)¶
-
express
()¶ Compile the gene to an evaluable object.
-
mate
(mate)¶ Perform a crossover with another gene of the same kind.
-
mutate
(indpb)¶ Perform a mutation on the gene.
-
static
patch_residue
(residue)¶
-
retrieve_rotamers
(molecule, position, residue, library='Dunbrack')¶
-
unexpress
()¶ Revert expression.
-
static
update_rotamer
(residue, chis)¶
- residues (list of str) –
-
gaudi.genes.rotamers.
enable
(**kwargs)¶
Search gene¶
This module provides spatial exploration of the environment.
It works by creating a sphere with radius self.radius and origin at self.origin. The movement is achieved with three matrices that contain a translation, a rotation, and a reference position.
It depends on gaudi.genes.molecule.Molecule
, since these are the ones
that will be moved around. Combined with the adequate objectives, this module
can be used to implement docking experiments.
-
class
gaudi.genes.search.
Search
(target=None, center=None, radius=None, rotate=True, precision=0, interpolation=0.5, **kwargs)¶ Bases:
gaudi.genes.GeneProvider
Parameters: - target (namedtuple or Name of gaudi.genes.molecule) – Can be either:
- The anchor atom of the molecule we want to move, with syntax
<molecule_name>/<index>
. For example, if we want to move Ligand using atom with serial number = 1 as pivot, we would specifyLigand/1
. It’s parsed to the actual chimera.Atom later on. - A name of gaudi.genes.molecule instance. In this case, the anchor atom for the movement of the molecule will be set to its nearest atom to the geometric center of the molecule. - center (3-item list or tuple of float, optional) – Coordinates to the center of the desired search sphere
- radius (float) – Maximum distance from center that the molecule can move
- rotate (bool, bool) – If False, don’t rotatate the molecule - only translation
- precision (int, bool) – Rounds the decimal part of the 3D search matrix to get a coarser model of space. Ie, less points can be accessed, the search is less exhaustive, more variability in less runs.
-
allele
¶ A 4x3 matrix of float, as explained in Notes.
Type: 3-tuple of 4-tuple of floats
-
origin
¶ The initial position of the requested target molecule. If we don’t take this into account, we can’t move the molecule around was not originally in the center of the sphere.
Type: 3-tuple of float
Notes
How matricial translation and rotation takes place
A single movement is summed up in a 4x3 matrix:
( (R1, R2, R3, T1), (R4, R5, R6, T2), (R7, R8, R9, T3) )R-elements contain the rotation information, while T elements account for the translation movement.
That matrix can be obtained from multipying three different matrices with this expression:
multiply_matrices(translation, rotation, to_zero)To understand the operation, it must be read from the right:
- First, translate the molecule the origin of coordinates 0,0,0
- In that position, the rotation can take place.
- Then, translate to the final coordinates from zero. There’s no need to get back to the original position.
How do we get the needed matrices?
to_zero
. Record the original position (origin) of the molecule and multiply it by -1. Done with method to_zero().rotation
. Obtained directly fromFitMap.search.random_rotation
translation
. Check docstring ofrandom_translation()
in this module.
-
center
¶
-
express
()¶ Multiply all the matrices, convert the result to a chimera.CoordFrame and set that as the xform for the target molecule. If precision is set, round them.
-
mate
(mate)¶ Interpolate the matrices and assign them to each individual. Ind1 gets the rotated interpolation, while Ind2 gets the translation.
-
molecule
¶
-
mutate
(indpb)¶ Perform a mutation on the gene.
-
origin
-
random_transform
()¶ Wrapper function to provide translation and rotation in a single call
-
to_zero
¶ Return a translation matrix that takes the molecule from its original position to the origin of coordinates (0,0,0).
Needed for rotations.
-
unexpress
()¶ Reset xform to unity matrix.
- target (namedtuple or Name of gaudi.genes.molecule) – Can be either:
- The anchor atom of the molecule we want to move, with syntax
-
gaudi.genes.search.
center
(mol)¶
-
gaudi.genes.search.
distance
(a, b)¶
-
gaudi.genes.search.
enable
(**kwargs)¶
-
gaudi.genes.search.
nearest_atom
(mol, position)¶
-
gaudi.genes.search.
parse_origin
(origin, individual=None)¶ The center of the sphere can be given as an Atom, or directly as a list of three floats (x,y,z). If it’s an Atom, find it and return the xyz coords. If not, just turn the list into a tuple.
Parameters: - origin (3-item list of coordinates, or chimera.Atom) –
- genes (gaudi.parse.Settings.genes) – List of gene-dicts to look for molecules that may contain the referred atom in origin
Returns: The x,y,z coordinates
Return type: Tuple of float
-
gaudi.genes.search.
rand_xform
(origin, destination, r, rotate=True)¶
-
gaudi.genes.search.
random_translation
(center, r)¶ Get a random point from the cube built with l=r and test if it’s within the sphere. Most of the points will be, but not all of them, so get another one until that criteria is met.
Parameters: - center (3-tuple of float) – Coordinates of the center of the search sphere
- r (float) – Radius of the search sphere
Returns: Return type: A translation matrix to a random point in the search sphere, with no rotation.
-
gaudi.genes.search.
rotate
(molecule, at, alpha)¶
-
gaudi.genes.search.
translate
(molecule, anchor, target)¶
Torsions gene¶
This module helps explore small molecules flexibility.
It does so by performing bond rotations in the selected gaudi.genes.molecule.Molecule objects, if they exhibit free bond rotations.
-
class
gaudi.genes.torsion.
Torsion
(target=None, flexibility=360.0, max_bonds=None, anchor=None, rotatable_atom_types=('C3', 'N3', 'C2', 'N2', 'P'), rotatable_atom_names=(), rotatable_elements=(), non_rotatable_bonds=(), rotatable_bonds=(), precision=1, **kwargs)¶ Bases:
gaudi.genes.GeneProvider
Parameters: - target (str) – Name of gaudi.genes.molecule instance to perform rotation on
- flexibility (int or float) – Maximum number of degrees a bond can rotate
- max_bonds – Expected number of free rotations in molecule. Needed to store arbitrary rotations.
- anchor (str) – Molecule/atom_serial_number of reference atom for torsions
- rotatable_atom_types (list of str) – Which type of atom types (as in chimera.Atom.idatmType) should rotate. Defaults to (‘C3’, ‘N3’, ‘C2’, ‘N2’, ‘P’).
- rotatable_atom_names (list of str) – Which type of atom names (as in chimera.Atom.name) should rotate. Defaults to ().
- rotatable_bonds (list of [SerialNumberAtom1, SerialNumberAtom2, SerialNumberAnchor]) – Concrete bonds that are allowed to rotate. Atoms have to be designated using their chimera serial number. IMPORTANT: if set, these will be the ONLY bonds allowed to rotate, ignoring other possible conditions (e.g. rotatable_atom_types, rotatable_atom_names…).
-
allele
¶ For i rotatable bonds in molecule, it contains i floats which correspond to each torsion angle. As such, each falls within [-180.0, 180.0).
Type: tuple of float
Notes
Todo
max_bonds is now automatically computed, but probably won’t deal nicely with block-built ligands.
-
BONDS_ROTS
= {}¶
-
anchor
¶ Get the molecular anchor. Ie, the root of the rotations, the fixed atom of the molecule.
Usually, this is the target atom in the Search gene, but if we can’t find it, get the nearest atom to the geometric center of the molecule, and if it’s not possible, the
donor
atom of the molecule.
-
clear_cache
()¶
-
express
()¶ Apply rotations to rotatable bonds
-
mate
(mate)¶ Perform a crossover with another gene of the same kind.
-
molecule
¶
-
mutate
(indpb)¶ Perform a mutation on the gene.
-
random_angle
()¶ Returns a random angle within flexibility limits
-
rotatable_bonds
¶ Gets potentially rotatable bonds in molecule
First, it retrieves all the atoms. Then, the bonds are filtered, discarding coordination (pseudo)bonds and sort them by atom serial.
For each bond, try to retrieve it from the cache. If unavailable, request a bond rotation object to chimera.BondRot.
In this step, we have to discard non rotatable atoms (as requested by the user), and make sure the involved atoms are of compatible type. Namely, one of them must be either C3, N3, C2 or N2, and both of them, non-terminal (more than one neighbor).
If the bond is valid, get the BondRot object. Chimera will complain if we already have requested that bond previously, or if the bond is in a cycle. Handle those exceptions silently, and get the next bond in that case.
If no exceptions are raised, then store the rotation anchor in the BondRot object (that’s the nearest atom in the bond to the molecular anchor), and store the BondRot object in the rotations cache.
-
unexpress
()¶ Undo the rotations
-
gaudi.genes.torsion.
center
(mol)¶
-
gaudi.genes.torsion.
distance
(a, b)¶
-
gaudi.genes.torsion.
enable
(**kwargs)¶
-
gaudi.genes.torsion.
nearest_atom
(mol, position)¶
Trajectory gene¶
This module provides spatial exploration of the environment through a MD trajectory file.
-
class
gaudi.genes.trajectory.
Trajectory
(target=None, path=None, max_frame=None, stride=1, preload=False, **kwargs)¶ Bases:
gaudi.genes.GeneProvider
Parameters: - target (str) – The Molecule that contains the topology of the trajectory.
- path (str) – Path to a MD trajectory file, as supported by mdtraj.
- max_frame (int) – Last frame of the trajectory that can be loaded.
- stride (int, optional) – Only load one in every stride frames
- preload (bool, optional) – Load the full trajectory in memory to accelerate expression. Not recommended for large files!
-
allele
¶ The index of a frame in the MD trajectory.
Type: int
-
_traj
¶ Alias to the frames cache
Type: dict
-
express
()¶ Load the frame requested by the current allele into a new CoordSet object (always at index 1) and set that as the active one.
-
load_frame
(n)¶
-
mate
(mate)¶ Simply exchange alleles. Can’t try to interpolate an intermediate structure because the result wouldn’t probably belong to the original trajectory!
-
molecule
¶ The target Molecule gene
-
mutate
(indpb)¶ Perform a mutation on the gene.
-
random_frame_number
()¶
-
topology
¶ Returns the equivalent mdtraj Topology object of the currently expressed Chimera molecule
-
unexpress
()¶ Set the original coordinates (stored at mol.coordSets[0]) as the active ones.
-
gaudi.genes.trajectory.
enable
(**kwargs)¶
Base class for all genes¶
Genes are modules that reside in the gaudi.genes package, and have a certain class structure.
-
class
gaudi.genes.
GeneProvider
(parent=None, name=None, cx_eta=5.0, mut_eta=5.0, mut_indpb=0.75, **kwargs)¶ Bases:
object
Base class that every genes plugin MUST inherit.
The methods listed here are compulsory for all subclasses, since the individual will be using them anyway. If it’s not relevant in your plugin, just define them with a single pass statement. Also, don’t forget to call GeneProvider.__init__ in your overriden __init__ function; it registers compulsory
— From (M.A. itself)[http://martyalchin.com/2008/jan/10/simple-plugin-framework/]: Now that we have a mount point, we can start stacking plugins onto it. As mentioned above, individual plugins will subclass the mount point. Because that also means inheriting the metaclass, the act of subclassing alone will suffice as plugin registration. Of course, the goal is to have plugins actually do something, so there would be more to it than just defining a base class, but the point is that the entire contents of the class declaration can be specific to the plugin being written. The plugin framework itself has absolutely no expectation for how you build the class, allowing maximum flexibility. Duck typing at its finest.
-
classmethod
clear_cache
()¶
-
express
()¶ Compile the gene to an evaluable object.
-
mate
(gene)¶ Perform a crossover with another gene of the same kind.
-
mutate
()¶ Perform a mutation on the gene.
-
plugins
= [<class 'gaudi.genes.search.Search'>, <class 'gaudi.genes.molecule.Molecule'>, <class 'gaudi.genes.mutamers.Mutamers'>, <class 'gaudi.genes.normalmodes.NormalModes'>, <class 'gaudi.genes.rotamers.Rotamers'>, <class 'gaudi.genes.torsion.Torsion'>, <class 'gaudi.genes.trajectory.Trajectory'>]¶
-
unexpress
()¶ Revert expression.
-
classmethod
validate
(data, schema=None)¶
-
classmethod
with_validation
(**kwargs)¶
-
write
(path, name, *args, **kwargs)¶ Write results of expression to a file representation.
-
classmethod