luna.mol.groups module¶
- class AtomGroup(atoms, features=None, interactions=None, recursive=True, manager=None)[source]¶
Bases:
objectRepresent single atoms, chemical functional groups, or simply an arrangement of atoms as in hydrophobes.
- Parameters
atoms (iterable of
ExtendedAtom) – A sequence of atoms.features (iterable of
ChemicalFeature, optional) – A sequence of chemical features.interactions (iterable of
InteractionType, optional) – A sequence of interactions established by an atom group.recursive (bool) – If True, add the new atom group to the list of atom groups of each atom in
atoms.manager (
AtomGroupsManager, optional) – TheAtomGroupsManagerobject that contains thisAtomGroupobject.
- add_features(features)[source]¶
Add
ChemicalFeatureobjects tofeatures.
- add_interactions(interactions)[source]¶
Add
InteractionTypeobjects tointeractions.
- as_json()[source]¶
Represent the atom group as a dict containing the atoms, compounds, features, and compound classes (water, hetero group, residue, or nucleotide).
The dict is defined as follows:
atoms(iterable ofExtendedAtom): the list of atoms comprising the atom group;compounds(iterable ofResidue): the list of unique compounds that contain the atoms;classes(iterable of str): the list of compound classes;features(iterable ofChemicalFeature): the atom group’s list of chemical features.
- property atoms¶
The sequence of atoms that belong to an atom group.
- Type
iterable of
ExtendedAtom, read-only
- property centroid¶
The centroid (x, y, z) of the atom group.
If
atomscontains only one atom, thencentroidreturns the same ascoords.- Type
array-like of floats, read-only
- clear_refs()[source]¶
References to this
AtomGroupinstance will be removed from the list of atom groups of each atom inatoms.
- property compounds¶
The set of unique compounds that contain the atoms in
atoms.As an atom group can be formed by the union of two or more compounds (e.g., amide of peptide bonds), it may return more than one compound.
- Type
set of
Residue, read-only
- contain_group(atm_grp)[source]¶
Check if the atom group
atm_grpis a subset of this atom group.For example, consider the benzene molecule. Its aromatic ring itself forms an
AtomGroupobject composed of all of its six atoms. Consider now any subset of carbons in the benzene molecule. This subset forms anAtomGroupobject that is part of the group formed by the aromatic ring. Therefore, in this example,contain_group()will return True because the aromatic ring contains the subset of hydrophobic atoms.
- property coords¶
Atomic coordinates (x, y, z) of each atom in
atoms.- Type
array-like of floats
- property feature_names¶
The name of each chemical feature in
features.- Type
iterable of str
- property features¶
A sequence of chemical features.
To add or remove a feature use
add_features()orremove_features(), respectively.- Type
iterable of
ChemicalFeature
- get_interactions_with(atm_grp)[source]¶
Get all interactions that an atom group establishes with another atom group
atm_grp.- Returns
All interactions established with the atom group
atm_grp.- Return type
iterable of
InteractionType
- get_shortest_path_length(trgt_grp, cutoff=None)[source]¶
Compute the shortest path length between this atom group to another atom group
trgt_grp.The shortest path between two atom groups is defined as the shortest path between any of their atoms, which are calculated using Dijkstra’s algorithm.
If
manageris not provided, None is returned.If there is not any path between
src_grpandtrgt_grp, infinite is returned.
- has_atom(atom)[source]¶
Check if an atom group contains a given atom
atom.- Parameters
atom (
ExtendedAtom)- Returns
If the atom group contains or not
atom.- Return type
- has_hetatm()[source]¶
Return True if at least one atom in the atom group belongs to a hetero group, i.e., non-standard residues of proteins, DNAs, or RNAs, as well as atoms in other kinds of groups, such as carbohydrates, substrates, ligands, solvent, and metal ions.
- has_nucleotide()[source]¶
Return True if at least one atom in the atom group belongs to a nucleotide.
- has_residue()[source]¶
Return True if at least one atom in the atom group belongs to a standard residue of proteins.
- has_water()[source]¶
Return True if at least one atom in the atom group belongs to a water molecule.
- property interactions¶
The sequence of interactions established by an atom group.
To add or remove an interaction use
add_interactions()orremove_interactions(), respectively.- Type
iterable of
InteractionType
- is_hetatm()[source]¶
Return True if all atoms in the atom group belong to hetero group, i.e., non-standard residues of proteins, DNAs, or RNAs, as well as atoms in other kinds of groups, such as carbohydrates, substrates, ligands, solvent, and metal ions.
Hetero groups are designated by the flag HETATM in the PDB format.
- is_mixed()[source]¶
Return True if the atoms in the atom group belong to different compound classes (water, hetero group, residue, or nucleotide).
- is_residue()[source]¶
Return True if all atoms in the atom group belong to standard residues of proteins.
- property manager¶
The
AtomGroupsManagerobject that contains anAtomGroupobject.- Type
- property normal¶
The normal vector (x, y, z) of the points given by
coords.- Type
array-like of floats, read-only
- remove_features(features)[source]¶
Remove
ChemicalFeatureobjects fromfeatures.
- remove_interactions(interactions)[source]¶
Remove
InteractionTypeobjects frominteractions.
- class AtomGroupNeighborhood(atm_grps, bucket_size=10)[source]¶
Bases:
objectClass for fast neighbor atom groups searching.
AtomGroupNeighborhoodmakes use of a KD Tree implemented in C, so it’s fast.- Parameters
- class AtomGroupPerceiver(feature_extractor, add_h=False, ph=None, amend_mol=True, mol_obj_type='rdkit', charge_model=<luna.mol.charge_model.OpenEyeModel object>, tmp_path=None, expand_selection=True, radius=2.2, critical=True)[source]¶
Bases:
objectPerceive and create atom groups for molecules.
- Parameters
feature_extractor (
FeatureExtractor) – Perceive pharmacophoric properties from molecules.add_h (bool) – If True, add hydrogen to the molecules.
ph (float, optional) – If not None, add hydrogens appropriate for pH
ph.amend_mol (bool) – If True, apply validation and standardization of molecules read from a PDB file.
mol_obj_type ({“rdkit”, “openbabel”}) – If “rdkit”, parse the converted molecule with RDKit and return an instance of
rdkit.Chem.rdchem.Mol. If “openbabel”, parse the converted molecule with Open Babel and return an instance ofopenbabel.pybel.Molecule.charge_model (class:
ChargeModel) – A charge model object. By default, the implementation of OpenEye charge model is used.tmp_path (str, optional) – A temporary directory to where temporary files will be saved. If not provided, the system’s default temporary directory will be used instead.
expand_selection (bool) – If True (the default), perceive features for a given molecule considering all nearby molecules. The goal is to identify any covalently bonded molecules that may alter the pharmacophoric properties or chemical functional groups.
For instance, consider an amide of a peptide bond. If
expand_selectionis False, the residues forming the peptide bond will be analyzed separately, which will make the oxygen and the nitrogen of the amide to be perceived as carbonyl oxygen and amine, respectively. On the other hand, ifexpand_selectionis True, the covalent bond between the residues will be identified and the amide will be correctly perceived.radius (float) – If
expand_selectionis True, select all molecules up to a maximum ofradiusaway (measured in Å). The default value is 2.2, which comprises covalent bond distances.critical (bool) – If False, ignore any errors during the processing a molecule and continue to the next one. The default value is True, which implies that any errors will raise an exception.
- Raises
IllegalArgumentError – If
mol_obj_typeis not either ‘rdkit’ nor ‘openbabel’.
- perceive_atom_groups(compounds, mol_objs_dict=None)[source]¶
Perceive and create atom groups for each molecule in
compounds.- Parameters
compounds (iterable of
Residue) – A sequence of molecules.mol_objs_dict (dict) – Map a compound, represented by its id, to a molecular object (
MolWrapper,rdkit.Chem.rdchem.Mol, oropenbabel.pybel.Molecule).This parameter can be used in cases where the ligand is read from a molecular file and no standardization or validation is required.
- Returns
An
AtomGroupsManagerobject containing all atom groups perceived for the molecules incompounds.- Return type
- class AtomGroupsManager(atm_grps=None, entry=None)[source]¶
Bases:
objectStore and manage
AtomGroupobjects.- Parameters
- Variables
~AtomGroupsManager.entry (
Entry) – The chain or molecule from where the atom groups were perceived.~AtomGroupsManager.graph (
networkx.Graph) – Represententryas a graph and its vicinity.~AtomGroupsManager.version (str) – The LUNA version when the object was created.
- add_atm_grps(atm_grps)[source]¶
Add one or more
AtomGroupobjects toatm_grpsand automatically updatechild_dict.
- property atm_grps¶
The sequence of
AtomGroupobjects. Additional objects should be added using the methodadd_atm_grps().- Type
iterable of
AtomGroup, read-only
- property child_dict¶
Mapping between atoms (
ExtendedAtom) and atom groups (AtomGroup).The mapping is a dict of {tuple of
ExtendedAtominstances :AtomGroup} and is automatically updated whenadd_atm_grps()is called.- Type
dict, read-only
- filter_by_types(types, must_contain_all=True)[source]¶
Filter
AtomGroupobjects by their physicochemical features.
- find_atm_grp(atoms)[source]¶
Find the atom group that contains the sequence of atoms
atoms.- Returns
An atom group object or None if
atomsis not in thechild_dictmapping.- Return type
AtomGroupor None
- get_all_interactions()[source]¶
Return all interactions established by the atom groups in
atm_grps.- Returns
All interactions.
- Return type
set of
InteractionType
- get_shortest_path_length(src_grp, trgt_grp, cutoff=None)[source]¶
Compute the shortest path length between two atom groups
src_grpandtrgt_grp.The shortest path between two atom groups is defined as the shortest path between any of their atoms, which are calculated using Dijkstra’s algorithm and the graph
graph.If there is not any path between
src_grpandtrgt_grp, infinite is returned.
- static load(input_file)[source]¶
Load the pickled representation of an
AtomGroupsManagerobject saved at the fileinput_file.- Returns
The reconstituted
AtomGroupsManagerobject, including its set of atom groups and interactions.- Return type
- Raises
PKLNotReadError – If the file could not be loaded.
- merge_hydrophobic_atoms(interactions_mngr)[source]¶
Create hydrophobic islands by merging covalently bonded hydrophobic atoms in
atm_grps. Hydrophobic islands are atom groups having the feature Hydrophobe.Atom-atom hydrophobic interactions in
interactions_mngrare also converted to island-island interactions.- Parameters
interactions_mngr (
InteractionsManager) – AnInteractionsManagerobject from where hydrophobic interactions are selected and convert from atom-atom to island-island interactions.
- new_atm_grp(atoms, features=None, interactions=None)[source]¶
Create a new
AtomGroupobject foratomsif one does not exist yet. Otherwise, return the existingAtomGroupobject.- Parameters
atoms (iterable of
ExtendedAtom) – A sequence of atoms.features (iterable of
ChemicalFeature, optional) – If provided, addfeaturesto a new or an already existingAtomGroupobject.interactions (iterable of
InteractionType, optional) – If provided, addinteractionsto a new or an already existingAtomGroupobject.
- Returns
A new or an already existing
AtomGroupobject.- Return type
- remove_atm_grps(atm_grps)[source]¶
Remove one or more
AtomGroupobjects fromatm_grpsand automatically updatechild_dict.Any recursive references to the removed objects will also be cleared.
- save(output_file, compressed=True)[source]¶
Write the pickled representation of the
AtomGroupsManagerobject to the fileoutput_file.- Parameters
output_file (str) – The output file.
compressed (bool, optional) – If True (the default), compress the pickled representation as a gzip file (.gz).
- Raises
FileNotCreated – If the file could not be created.
- class PseudoAtomGroup(parent_grp, atoms, features=None, interactions=None)[source]¶
Bases:
luna.mol.groups.AtomGroupRepresent only the atoms from an
AtomGroupobject that are involved in an interaction.Currently, this class is only used during the generation of LUNA’s fingerprints.
- Parameters
parent_grp (
AtomGroup) – The atom group that contains the subset of atomsatoms.atoms (iterable of
ExtendedAtom) – A sequence of atoms.features (iterable of
ChemicalFeature, optional) – A sequence of chemical features.interactions (iterable of
InteractionType, optional) – A sequence of interactions established by an atom group.