vermouth.processors.repair_graph module

Provides a processor that repairs a graph based on a reference.

class vermouth.processors.repair_graph.RepairGraph(delete_unknown=False, include_graph=True)[source]

Bases: Processor

Repairs a molecule such that it contains all atoms with appropriate atom names, as per the blocks in the system’s force field, while taking any mutations and modification into account. These should be added as ‘mutation’ and ‘modification’ attributes to the atoms of the relevant residues.

delete_unknown

If True, removes any molecules that contain residues that are not known to the system’s force field.

Type:

bool

include_graph

If True, every node in the resulting graph will have a ‘graph’ attribute containing a subgraph constructed using the input atoms.

Type:

bool

See also

repair_graph()

run_molecule(molecule)[source]
run_system(system)[source]
vermouth.processors.repair_graph.get_default(dictionary, attr, default)[source]

Functions like dict.get(), except that when attr is in dictionary and dictionary[attr] is None, it will return default.

Parameters:
Returns:

The value of dictionary[attr] if attr is in dictionary and dictionary[attr] is not None. default otherwise.

Return type:

object

vermouth.processors.repair_graph.make_reference(mol)[source]

Takes an molecule graph (e.g. as read from a PDB file), and finds and returns the graph how it should look like, including all matching nodes between the input graph and the references. Requires residue names to be correct.

Notes

The match between hydrogren atoms need not be perfect. See the documentation of isomorphism.

Parameters:

mol (networkx.Graph) –

The graph read from e.g. a PDB file. Required node attributes:

resname:

The residue name.

resid:

The residue id.

chain:

The chain identifier.

element:

The element.

atomname:

The atomname.

Returns:

The constructed reference graph with the following node attributes:

resid:

The residue id.

resname:

The residue name.

chain:

The chain identifier.

found:

The residue subgraph from the PDB file.

reference:

The residue subgraph used as reference.

match:

A dictionary describing how the reference corresponds with the provided graph. Keys are node indices of the reference, values are node indices of the provided graph.

Return type:

networkx.Graph

vermouth.processors.repair_graph.repair_graph(molecule, reference_graph, include_graph=True)[source]

Repairs a molecule graph produced based on the information in reference_graph. Missing atoms will be added and atom- and residue- names will be canonicalized. Atoms not present in reference_graph will have the attribute PTM_atom set to True.

molecule is modified in place. Missing atoms (as per reference_graph) are added, atom and residue names are canonicalized, and PTM atoms are marked.

If include_graph is True, then the subgraph corresponding to each node is included in the node under the “graph” attribute.

Parameters:
  • molecule (molecule.Molecule) –

    The graph read from e.g. a PDB file. Required node attributes:

    resname:

    The residue name.

    resid:

    The residue id.

    element:

    The element.

    atomname:

    The atomname.

  • reference_graph (networkx.Graph) –

    The reference graph as produced by make_reference(). Required node attributes:

    resid:

    The residue id.

    resname:

    The residue name.

    found:

    The residue subgraph from the PDB file.

    reference:

    The residue subgraph used as reference.

    match:

    A dictionary describing how the reference corresponds with the provided graph. Keys are node indices of the reference, values are node indices of the provided graph.

  • include_graph (bool) – Include the subgraph in the nodes.

vermouth.processors.repair_graph.repair_residue(molecule, ref_residue, include_graph)[source]

Rebuild missing atoms and canonicalize atomnames