QMzymeRegion
- class QMzyme.QMzymeRegion.QMzymeRegion(name, atoms: list, atom_group=None, universe=None)
Product of the RegionBuilder class. A QMzymeRegion is composed of QMzymeAtom objects.
See also
QMzymeRegion.QMzymeResidue
- property ids
A list of atom numbers/ids from the original starting structure. An atom id of an atom from the starting structure should not change.
- property ix_array
A list of atom indices starting from 0. If the order of atoms changes the ix assigned to an atom will change. See ids as an alternative.
See also
- property resids
- Returns:
Sorted residue IDs for residues within this region.
- Return type:
list
- property n_atoms
- Returns:
Number of atoms within this region.
- Return type:
int
- property n_residues
- Returns:
Number of residues within this region.
- Return type:
int
- property residues
- Returns:
Residues in this region.
- Return type:
List[
QMzymeResidue]
- property positions
- Returns:
Positions of all atoms in region.
- Return type:
NumPy array
- property atom_group
Returns the
AtomGroupinstance. If the region was not bult from an AtomGroup initially, it will be converted to one. Note, in this case, the universe of that AtomGroup will
- property segids
- property creation_attr
Filters _selection_attr into _creation_attr. Ultimately, it creates a property to the region of how the region was created. :rtype: List[
creation_attr]
- reset_creation_attr()
Resets the selection and creation parameters for the region.
- set_creation_attr(attr=None, **kwargs)
Manually sets or updates the selection parameters for the region. This is particularly useful for assigning parameters to internally generated regions that need to inherit the creation history of their parent selection scheme.
- get_atom(id)
Selects the atom with set atom ID.
- Parameters:
id (float) -- The id of an atom you want to select.
- has_atom(id)
Examines if specific atom exists within the region.
- Parameters:
id (int) -- The ID of an atom you want to check for existance in the region.
- has_residue(resid)
Examines if specific residue exists within the region.
- Parameters:
resid (int) -- The residue ID you want to check for existance in the region.
- add_atom(atom: _QMzymeAtom, override_same_id=False)
Adds additional QMzymeAtom to the QMzymeRegion.
- Parameters:
atom (
QMzymeAtom, required) -- The atom you want to add to the QMzymeRegion.overrisde_same_id (bool, optional) -- An argument to decide if the atoms with same IDs are replaced.
Warning
Ths will modify the QMzymeRegion directly.
- remove_atom(atom: _QMzymeAtom)
Removes QMzymeAtom from the QMzymeRegion.
- Parameters:
atom (
QMzymeAtom, required) -- The atom you want to remove from the QMzymeRegion.overrisde_same_id (bool, optional) -- An argument to decide if the atoms with same IDs are replaced.
Warning
Ths will modify the QMzymeRegion directly.
- sorted_atoms(override_same_id=False)
Returns a list of atoms sorted by their IDs, with optional duplicate handling. This method checks the most recently added atom's ID against prexisting atoms' IDs. If a duplicate ID is found and override_same_id=False, warning is raised. If override_same_id=True, it will replace older atom and replace it with newer atom with same ID.
- Parameters:
overrisde_same_id (bool, optional) -- An argument to decide if the atoms with same IDs are replaced.
- Returns:
A list of QMzymeAtom objects sorted numerically by their atom IDs.
- Return type:
list
- get_residue(resid)
Retrieve a residue from the QMzymeRegion.
- Parameters:
resid (int) -- The resid of the QMzymeResidue within QMzymeRegion.
- Returns:
The corresponding QMzymeResidue object if found, otherwise None.
- Return type:
- rename(name)
Rename the region.
- Parameters:
name (str) -- The new name for the QMzymeRegion.
- write(filename=None, format='pdb')
Converts QMzymeRegion to an MDAnalysis AtomGroup, then uses the AtomGroup method to write file.
- Parameters:
filename (str, optional) -- Name of file. If not specified, the region name attribute will be used. If the region name is an empty string the name will become 'noname'. Note, if you specify a file format in filename (i.e., filename='name.xyz'), but the value of the 'format' argument does not match, the value assigned to format will be used.
format (str, default='pdb') -- Format of created file.
Note
Any file ending supported by the MDAnalysis AtomGroup write method is supported as long as all the necessary information to write that file type is present in the region.
- set_fixed_atoms(ids: list = None, atoms: list = None)
Example Usage: To fix all alpha carbons >>> ids = get_ids(attribute='type', value='CA') >>> set_fixed_atoms(ids=ids)
- Parameters:
ids (List[int], optional, default=None) -- Atom ids in QMzymeRegion to fix.
atoms (List[
QMzymeAtom], default=None) -- Atoms in QMzymeRegion to fix.
Note
Must specify either ids or atoms (if both are specified, atoms will be used). During calculation file writing if an atom has attribute
is_fixed=True, that atom will be frozen.
- get_ids(attribute: str, value)
- Example:
To fix all alpha carbons >>> ids = get_ids(attribute='type', value='CA') >>> set_fixed_atoms(ids=ids)
- Parameters:
attribute (str, required) -- QMzymeAtom object attribute name.
value (Depends on the attribute, required) -- Value of interest for the corresponding attribute.
- Returns:
atom ids.
- Return type:
List[int]
See also
- get_atoms(attribute: str, value)
- Example:
To see what atoms are in residue with resid 14. > atoms = get_atoms(attribute='resid', value=14)
- Parameters:
attribute (str, required) -- QMzymeAtom object attribute name.
value (Depends on the attribute, required) -- Value of interest for the corresponding attribute.
- Returns:
atom ids.
- Return type:
List[int]
List[
QMzymeAtom]See also
- get_indices(attribute: str, value)
Get the indices of QMzymeAtoms that match a specific attribute value.
- Parameters:
attribute (str) -- The name of the atom attribute to filter by (e.g., 'resname', 'Val').
value (str) -- The value the attribute must match.
- Returns:
A list of integer indices representing QMzymeAtom IDs.
- Return type:
list[int]
- get_ix_array_from_ids(ids)
- Example:
>>> ixs = get_ids(attribute='type', value='CA')
- check_missing_attr(attr)
Verify that all atoms in the region possess a specific attribute.
Checks all QMzymeAToms within the QMzymeRegion for the presence of specific attribute. If any QMzymeAtoms are missing the attribute, a warning is raised.
- Parameters:
attr (str) -- The name of the attribute.
- Raises:
UserWarning -- If one or more QMzymeAtoms lack the attribute or if the attribute is None.
- set_method(method)
This method designates a specific QM method to the QMzymeRegion. This is used by the :module:`~QMzyme.CalculateModel` module when the region is passed to a Calculation Method class.
- Parameters:
method (dict) -- The method that is going to be applied to QMzymeRegion.
- set_charge(charge)
Sets specific charge to QMzymeRegion :param charge: The charge of the QMzymeRegion. :type charge: int
- guess_charge(verbose=True)
Guesses charge based on the residue_charges information in QMzymeconfiguration__init__.py. QMzyme contains charge information of standard AMBER amino acid residues. If non-AMBER residues are present, it will raise an error. To update the charge of the unknown residue, the user can use QMzyme.data.residue_charges.update({'unknown residue name': int})
- Parameters:
verbose (bool) -- Returns print statements including warning and estimated charge.
- read_charges(verbose=True)
Calculates total charge of QMzymeResidue by using tolopogy attribute 'charge'.
- Parameters:
verbose (bool) -- Returns print statements including warning and estimated charge.
- combine(other, name=None)
Combine region with another region.
- Parameters:
other (
QMzymeRegion) -- Region containing atoms to combine with self.name (str, default=None) -- Name of returned region. If no name is specified the name will be 'self.name_other.name_combined.'.
- Returns:
Combined region.
- Return type:
Note
Self region is not altered, and returned region will not contain properties or attributes of self region not described from the QMzymeAtom level (i.e., atom_group) except for _universe. Atoms found in both self and other will only be copied from self. This is important if you have different attribute values on an atom that appears in both regions (i.e., is_fixed=True and is_fixed=False).
- subtract(other, name='')
Creates a new QMzymeRegion that does not contain any atoms found in other.
- Parameters:
other (
QMzymeRegion) -- Region containing atoms to remove from self.name (str, default='') -- Name of returned region.
- Returns:
New region with atoms found in other region removed.
- Return type:
Note
Self region is not altered, and returned region will not contain properties or attributes of self region not described from the QMzymeAtom level (i.e., atom_group) except for _universe.
- get_overlapping_atoms(other)
- Parameters:
other (
QMzymeRegion) -- Other QMzymeRegion to measure overlap with.- Returns:
Atoms in self that are also found in other.
- Return type:
- set_atom_segid(segid)
Sets segment id attribute to QMzymeAtom objects within QMzymeResidue.
- Parameters:
segid (int) -- segment id of the QMzymeAtom
- summarize(filename=None)
Creates a summary of QMzymeRegion, which includes resid, resname, charge, removed atoms, and fixed atoms of QMzymeResidues within QMzymeRegion. If a file name is specified, the summary will be created as a .txt file. Else, it will return a dictionary with summary information.
- Parameters:
filename (str) -- Name of the output file for the summarized information.
- align_to(other, self_selection='all', other_selection='all', update_region=True)
This method aligns the selection of QMzymeAtom objects within self QMzymeRegion to the specified selection of QMzymeAtom objects from a QMzymeRegion. The computed RMSD of pre- and post-alignment is printed. It is important to align the smaller subset of QMzymeAtom objects (self) to the QMzymeAtom objects of larger QMzymeRegion (other) to align the smaller subset to the larger QMzymeRegion. This can be ensured by specifying the smaller model before the “align_to” function. This will assign the smaller model to “self”.
- Parameters:
other (QMzymeRegion) -- QMzymeRegion of the other QMzymeAtoms for alignment.
self_selection (str) -- Selection of QMzymeAtoms based on MDAnalysis selection nomenclatire.
other_selection (str) -- Selection of QMzymeAtoms based on MDAnalysis selection nomenclatire.
- Parm update_region:
Updates the aligned QMzymeAtom objects to the QMzymeRegion.
- find_nearby_residues(other, dist)
Finds residues in 'other' region that have at least one atom within 'dist' Angstroms of any atom in 'self' region.
- Parameters:
other (
QMzymeRegion) -- The target region to search within for nearby residues.dist (float) -- The distance cutoff in Angstroms.
- Returns:
List of unique residues from the other region within the cutoff distance.
- Return type:
list of
QMzymeResidue
Returns: list of unique QMzymeResidue objects from the 'other' region.
- store_calculation_results(calculation_file)
Once you run a calculation on a QMzymeRegion you can then store the calculation results. This method uses cclib to parse the output, so any calculation file that cclib can read can be stored to your QMzymeRegion, and the stored dictionary will contain all the data that cclib parses.