vermouth.processors.canonicalize_modifications module¶
Provides a Processor that identifies unexpected atoms such as PTMs and protonations, and canonicalizes their attributes based on modifications known in the forcefield.
- class vermouth.processors.canonicalize_modifications.CanonicalizeModifications[source]¶
Bases:
Processor
Identifies all modifications in a molecule and corrects their atom names.
See also
- vermouth.processors.canonicalize_modifications.allowed_ptms(residue, res_ptms, known_ptms)[source]¶
Finds all PTMs in
known_ptms
which might be relevant forresidue
.- Parameters:
residue (networkx.Graph)
res_ptms (list[tuple[set, set]]) – As returned by
find_PTM_atoms
. Currently not used.known_ptms (collections.abc.Mapping[str, networkx.Graph])
- Yields:
tuple[networkx.Graph, networkx.isomorphism.GraphMatcher] – All graphs in known_ptms which are subgraphs of residue.
- vermouth.processors.canonicalize_modifications.find_ptm_atoms(molecule)[source]¶
Finds all atoms in molecule that have the node attribute
PTM_atom
set to a value that evaluates toTrue
.molecule
will be traversed starting at these atoms until all marked atoms are visited such that they are identified per “branch”, and for every branch the anchor node is known. The anchor node is the node(s) which are not PTM atoms and share an edge with the traversed branch.- Parameters:
molecule (networkx.Graph)
- Returns:
[({ptm atom indices}, {anchor indices}), ...]
. Ptm atom indices are connected, and are connected to the rest of molecule via anchor indices.- Return type:
- vermouth.processors.canonicalize_modifications.fix_ptm(molecule)[source]¶
Canonizes all PTM atoms in molecule, and labels the relevant residues with which PTMs were recognized. Modifies
molecule
such that atom names of PTM atoms are corrected, and the relevant residues have been labeled with which PTMs were recognized.- Parameters:
molecule (networkx.Graph) – Must not have missing atoms, and atom names must be correct. Atoms which could not be recognized must be labeled with the attribute PTM_atom=True.
- vermouth.processors.canonicalize_modifications.identify_ptms(residue, residue_ptms, known_ptms)[source]¶
Identifies all PTMs in
known_PTMs
necessary to describe all PTM atoms inresidue_ptms
. Will take PTMs such that all PTM atoms inresidue
will be covered by applying PTMs fromknown_PTMs
in order. Nodes inresidue
must have correctatomname
attributes, and may not be missing. In addition, every PTM in must be anchored to a non-PTM atom.- Parameters:
residue (networkx.Graph) – The residues involved with these PTMs. Need not be connected.
residue_ptms (list[tuple[set, set]]) – As returned by
find_PTM_atoms
, but only those relevant forresidue
.known_PTMs (collections.abc.Sequence[tuple[networkx.Graph, networkx.isomorphism.GraphMatcher]]) – The nodes in the graph must have the PTM_atom attribute (True or False). It should be True for atoms that are not part of the PTM itself, but describe where it is attached to the molecule. In addition, its nodes must have the atomname attribute, which will be used to recognize where the PTM is anchored, or to correct the atom names. Lastly, the nodes may have a replace attribute, which is a dictionary of
{attribute_name: new_value}
pairs. The special case here is if attribute_name is'atomname'
and new_value isNone
: in this case the node will be removed. Lastly, the graph (not its nodes) needs a ‘name’ attribute.
- Returns:
All PTMs from
known_PTMs
needed to describe the PTM atoms inresidue
along with adict
of node correspondences. The order ofknown_PTMs
is preserved.- Return type:
- Raises:
KeyError – Not all PTM atoms in
residue
can be covered withknown_PTMs
.
- vermouth.processors.canonicalize_modifications.ptm_node_matcher(node1, node2)[source]¶
Returns True iff node1 and node2 should be considered equal. This means they are both either marked as PTM_atom, or not. If they both are PTM atoms, the elements need to match, and otherwise, the atom names must match.