boltzkit.utils.molecular.z_matrix_factory
This file utilizes a modified version of the ZMatrixFactory from https://github.com/noegroup/bgmol.
MIT License
Copyright (c) 2020 noegroup
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Functions
|
A stupid function to build an MDtraj topology with limited information. |
|
Find rings in a molecule. |
|
True for all torsions that define HA positions. |
|
Whether torsions are the first (proper) torsion of a methyl group. |
|
Whether torsions are proper or improper dihedrals. |
|
Whether torsions are Ramachandran angles or not. |
|
Whether torsions are part of defining a ring. |
|
Whether torsions are of the specified type. |
|
Redefine all torsions containing HA as HA-CA-N-C torsions. |
Classes
Factory for internal coordinate representations. |
- boltzkit.utils.molecular.z_matrix_factory.find_rings(mdtraj_topology: Topology)[source]
Find rings in a molecule.
- Returns:
ring_atoms – Atoms constituting each ring
- Return type:
List[List[int]]
Notes
Requires networkx.
- boltzkit.utils.molecular.z_matrix_factory.is_ring_torsion(torsions: Sequence[Sequence[int]], mdtraj_topology: Topology)[source]
Whether torsions are part of defining a ring.
- Returns:
is_ring – A boolean array which contains 1 for torsions of ring atoms and 0 for others
- Return type:
np.ndarray
Notes
Requires networkx.
- boltzkit.utils.molecular.z_matrix_factory.is_proper_torsion(torsions: Sequence[Sequence[int]], mdtraj_topology: Topology)[source]
Whether torsions are proper or improper dihedrals.
- Parameters:
torsions (np.ndarray or Sequence[Sequence[int]]) – A list of torsions or a zmatrix.
mdtraj_topology (md.Topology)
- Returns:
is_proper – A boolean array which contains 1 for proper and 0 for improper torsions.
- Return type:
np.ndarray
- boltzkit.utils.molecular.z_matrix_factory.is_methyl_torsion(torsions: Sequence[Sequence[int]], mdtraj_topology: Topology, general: bool = False)[source]
Whether torsions are the first (proper) torsion of a methyl group. Methyl hydrogens are placed by one proper and two improper torsions. This function only indicates the former.
- Parameters:
torsions (np.ndarray or Sequence[Sequence[int]]) – A list of torsions or a zmatrix.
mdtraj_topology (md.Topology)
general (bool) – If true any group containing three H atoms is selected, not just methyl.
- Returns:
is_methyl – A boolean array which contains 1 for proper methyl torsion and 0 otherwise
- Return type:
np.ndarray
- boltzkit.utils.molecular.z_matrix_factory.is_chiral_torsion(torsions: Sequence[Sequence[int]], mdtraj_topology: Topology)[source]
True for all torsions that define HA positions.
- boltzkit.utils.molecular.z_matrix_factory.is_type_torsion(type_torsion: str, torsions: Sequence[Sequence[int]], mdtraj_topology: Topology)[source]
Whether torsions are of the specified type. Types supported are: ramachandran, phi, psi, omega, chi, chi1, chi2, chi3, chi4, ring, proper, methyl, chiral
- Parameters:
type_torsion (str) – Which type of torsion among the supported ones.
torsions (np.ndarray or Sequence[Sequence[int]]) – A list of torsions or a zmatrix.
mdtraj_topology (md.Topology)
- Returns:
is_type – A boolean array which contains True iff the torsion is of the specified type.
- Return type:
np.ndarray
- boltzkit.utils.molecular.z_matrix_factory.is_ramachandran_torsion(torsions: Sequence[Sequence[int]], mdtraj_topology: Topology)[source]
Whether torsions are Ramachandran angles or not.
- Parameters:
torsions (np.ndarray or Sequence[Sequence[int]]) – A list of torsions or a zmatrix.
mdtraj_topology (md.Topology)
- Returns:
is_ramachandran – A boolean array which contains True iff the torsion is Ramachandran
- Return type:
np.ndarray
- boltzkit.utils.molecular.z_matrix_factory.rewire_chiral_torsions(z_matrix: ndarray, mdtraj_topology: Topology, verbose=True)[source]
Redefine all torsions containing HA as HA-CA-N-C torsions. We use those to define chirality of aminoacids.
- Parameters:
z_matrix (np.ndarray) – A matrix of atom indices defining the internal coordinate transform.
mdtraj_topology (md.Topology)
- Returns:
z_matrix – A modified z-matrix that has all HA positions conditioned on CA, N, C
- Return type:
np.ndarray
Notes
The indices do not correspond directly to indices
- class boltzkit.utils.molecular.z_matrix_factory.ZMatrixFactory[source]
Bases:
objectFactory for internal coordinate representations.
- Parameters:
mdtraj_topology (mdtraj.Topology) – The system’s topology.
cartesian (str or sequence of ints) – The ids of atoms that are not transformed into internal coordinates. This can either be a sequence of integers or a DSL selection string for mdtraj.
- z_matrix
The internal coordinate definition of shape (n_atoms - n_cartesian, 4). For each line, the placing of atom line[0] is conditioned on the atoms line[1:3]. Negative entries (-1) in a line mean that the atom is a seed for the global transform.
- Type:
np.ndarray
- fixed
One-dimensional array of cartesian atom indices.
- Type:
np.ndarray
- property z_matrix
- property fixed
- build_naive(subset='all', render_independent=True, rewire_chiral=True, verbose=False)[source]
Place atoms relative to the closest atoms that are already placed (wrt. bond topology).
- Parameters:
subset (str or sequence of int) – A selection string or list of atoms. The z-matrix is only build for the subset.
render_independent (bool) – Whether to make sure that no two positions depend on the same three other positions.
rewire_chiral (bool) – Whether to make sure that all HA depend on (CA, N, C).
- Returns:
z_matrix (np.ndarray)
fixed_atoms (np.ndarray)
- build_with_templates(*yaml_files, template_lookup_dir: str = '/home/runner/work/boltzkit/boltzkit/src/boltzkit/utils/molecular/z_matrix_templates', build_protein_backbone=True, subset='all')[source]
Build ICs from template files.
- Parameters:
*yaml_files (str) – filenames of any other template files; if non are passed, use the bundled “z_protein.yaml”, “z_termini.yaml”
template_lookup_dir (str) – Directory path to look up the templates
build_protein_backbone (bool) – Whether to build the protein backbone first
subset (str or sequence of int) – A selection string or list of atoms. The z-matrix is only build for the subset.
Notes
For the formatting of template files, see data/z_protein.yaml
- Returns:
z_matrix (np.ndarray)
fixed_atoms (np.ndarray)
- build_with_system(system)[source]
Idea: build a lookup table of torsions and impropers; sort them by marginal entropy. Before doing the naive lookup, try to insert in the minimum-entropy torsions. Maybe: also do something regarding symmetries.
- boltzkit.utils.molecular.z_matrix_factory.build_fake_topology(n_atoms, bonds=None, atoms_by_residue=None, coordinates=None)[source]
A stupid function to build an MDtraj topology with limited information.
- Returns:
topology (md.Topology)
trajectory (md.Trajectory or None) – None, if no coordinates were specified.