Vermouth and Martinize2

repository·master·Indexed 40 days ago

https://github.com/marrink-lab/vermouth-martinize

Tools for molecular topology generation and resolution transformation, specifically designed to transform atomistic structures into coarse-grained structures and topologies for the Martini force field. The project includes Martinize2, a command-line tool for producing coarse-grained structures, and Vermouth, a Python library that uses graph algorithms to describe and apply transformations on molecular structures.

Tokens
28.5K
Snippets
85
Records
129
Agent score
94%

What's inside Vermouth

  1. What are Martinize2 and vermouth?

    master

    The project consists of two main components:

    1. Martinize2: A tool aimed at producing coarse-grained structures and topologies from atomistic structures. It is primarily developed for the Martini coarse-grained force field and the Gromacs simulation engine.
    2. Vermouth (VERsatile, MOdular, and Universal Tranformation Helper): The Python library that powers Martinize2. It allows users to describe and apply transformations on molecular structures and topologies using graph algorithms.
  2. What is the MartiniGō model?

    master

    The MartiniGō model is a method for maintaining protein secondary and tertiary structure using native contacts. Unlike standard elastic networks, it applies non-bonded Lennard-Jones interactions between pairs of beads based on residue overlap and specific chemical structural unit criteria.

    In Martinize2 (version ≥ 0.10.0), these interactions are mediated by adding extra virtual sites on top of the protein's backbone beads. These interactions are exported as separate .itp files to be included in the protein topology.

  3. Use Links to describe inter-residue interactions

    master

    A vermouth.molecule.Link describes interactions that occur between residues. It defines nodes, edges, and changes to MD parameters (adding, changing, or removing interactions/attributes) applied to a specific molecular fragment.

    Key concepts:

    • Matching: Links use non-edges (where an edge must not exist in the molecule) and patterns (conditions that must be met, such as specific secondary structures) to match against a molecule.
    • Efficiency: Instead of defining all parameters from scratch, Links are designed to only affect parameters that depend on the local structure, making topology construction more efficient and easier to reason about.
    • Definition: Links are typically defined in .ff (Force Field) files.
  4. Structure of a VerMoUTH Force Field

    master

    A vermouth.forcefield.ForceField is a collection of:

    • vermouth.molecule.Block objects
    • vermouth.molecule.Link objects
    • vermouth.molecule.Modification objects

    Important notes:

    • Identification: Each force field is identified by a unique name attribute. Within a force field, all blocks and modifications must also have unique names.
    • Scope: A VerMoUTH Force Field is a subset of a traditional MD force field; it contains structural information and particle types (atype), but does not include non-bonded parameters (like Lennard-Jones) or functional forms.
  5. Use exponential decay for elastic bond strength

    master

    To tune the strength of the elastic bond based on distance, use an exponential decay function. The force constant of a bond is the value provided in -ef multiplied by the decay result. The decay is calculated as:

    $$decay = e^{(-f * ((x - s)^p))}$$

    Where:

    • $f$ = decay factor (-ea)
    • $p$ = decay power (-ep)
    • $s$ = decay shift (-es)

    Key behaviors:

    • The strength is never allowed to exceed the value set by -ef.
    • The shift -es moves the decay function along the distance axis but does not remove bonds (unlike the hard cutoff -el).
  6. Understand the Martinize 2 Workflow Pipeline

    master

    Martinize 2 is the primary CLI entry point for vermouth. It processes molecular structures through a 6-stage pipeline to prepare them for simulations:

    1. Reading input files: Parsing .gro or .pdb files.
    2. Repairing the input molecule: Completing the graph, fixing atom names, and identifying modifications.
    3. Mapping to force field/resolution: Mapping the molecule to the desired output force field.
    4. Applying Links: Generating inter-residue interactions.
    5. Post-processing: Tasks like building an elastic network.
    6. Writing output files.

    Key Concept: Connectivity-based Identification Throughout the pipeline, the recognition and identification of atoms and particles are based on their connectivity (edges in a graph) in addition to their atom properties. A 'molecule' is treated as a connected graph of atoms and edges, which may include non-protein connections like disulphide bridges.

  7. Apply interactions between residues using DoLinks

    master

    Interactions between residues are added using the vermouth.processors.do_links.DoLinks processor. This uses the concept of Links, which are molecular fragments describing interactions and the atoms they apply to.

    Key Concepts

    • Purpose: Links generate interactions that depend on local structure, such as protein sequence or secondary structure.
    • Order of Application: Links can add, change, or remove interactions/nodes. They are applied in the order they are defined in the force field files. You should define links from most general to most specific.
    • Matching Logic: For a link to match, all its node attributes must match.
    • The 'order' attribute: This is a special case where attributes are translated to differences in residue numbers. For example, nodes BB and +BB must have a residue number difference of exactly 1. For non-linear polymers, you may need to use order specifications like > (greater than) or * (different from) to avoid complications.
    • Overlapping Links: Links can overlap. For example, the link BB *BB will be applied both forwards and backwards.
  8. Syntax for mutations and modifications in Martinize2

    master

    Martinize2 uses a specific syntax to define mutations and modifications. The general pattern is:

    <chain>-<resname><resid>:<new resname>

    Parts of this syntax can be omitted depending on whether you want to target a specific residue or all residues of a certain type.

    Important Note on Coordinates: Martinize2 does not build new coordinates for mutations. While the mutation will correctly update the topology file with the necessary parameters, the resulting coordinate file will contain NaN values because the tool cannot reconstruct the necessary mappings for the new residue's geometry.

  9. Repair the Input Graph and Identify Modifications

    master

    The RepairGraph stage ensures the input molecule matches the reference force field's data:Block (including atom names and counts).

    How Repair Works:

    1. Atom Identification: Uses a Maximum Common Induced Subgraph (ISMAGS) algorithm to match input atoms to the reference. This handles both missing atoms and extra atoms (from PTMs).
    2. Modification Identification: Atoms not recognized by the standard residue block are processed by CanonicalizeModifications. These are identified by finding an induced subgraph that matches a known data:Modification and contains at least one "anchoring" atom (an atom also described by a data:Block).

    Warnings:

    • unknown-residue: No data:Block found for a residue; the molecule will be removed.
    • unknown-input: A modification cannot be identified; the involved atoms will be removed.

    Note on Performance: ISMAGS is computationally expensive (exponential scaling). If using very large PTMs (e.g., lipidations), consider specifying them as separate residues to improve speed.

  10. Perform resolution transformation with DoMapping

    master

    The resolution transformation converts your molecule to a target resolution (force field) using mappings. This is handled by the vermouth.processors.do_mapping.DoMapping processor.

    How it works

    • Mappings: The processor reads .map and .mapping files which describe how molecular fragments (nodes and edges) correspond to blocks in the target force field.
    • Matching: For a fragment to match, atom and residue names must match the input molecule. It is highly recommended to run the Repair the input graph step before this to ensure you are using canonical atom names.
    • Connectivity: Edges within blocks are taken from the target force field. Edges between blocks are generated based on the connectivity of the input molecule.
    • Automatic Mappings: If the target force field (-ff) and the original force field (-from) are the same, mappings are generated automatically.

    Warnings and Errors

    • unmapped-atom: Issued if atoms in the input molecule (or non-hydrogen atoms) cannot be found in any mapping.
    • inconsistent-data: A serious error issued if:
      • Multiple modification or block mappings overlap.
      • An output particle is constructed from input atoms with inconsistent residue-level attributes (e.g., different residue names/numbers).
      • An atom maps to multiple disconnected output particles.
      • An interaction is being set by multiple mappings.
    Relevant CLI options:
    - `-ff`: Target force field
    - `-map-dir`: Directory containing mapping files
  11. How Vermouth uses graph algorithms for atom identification

    master

    Vermouth identifies atoms and molecular fragments by treating them as graphs where atoms are nodes and bonds are edges. Instead of relying solely on atom names, the system uses the connectivity (the arrangement of nodes and edges) to determine atom identity.

    This identification is achieved through two primary methods depending on the workflow step:

    1. Maximum Common Induced Subgraph: Used during the Repair graph step to find the best possible overlay between a molecule and reference graphs (like blocks).
    2. Induced Subgraph Isomorphism: Used in other workflow steps where atom names are assumed to be correct and are used as constraints to simplify the matching process.
  12. Implement a custom Processor

    master

    Processors are the fundamental building blocks of the martinize2 pipeline. To create a custom processor, you must implement either the run_system method or the run_molecule method from the vermouth.processors.processor.Processor class.

    Choosing between run_system and run_molecule

    • run_molecule (Preferred): Use this if your processor can operate on individual molecules independently. The default run_system implementation automatically iterates over all molecules in a system and calls run_molecule on each. This method must return a Molecule object (either a modified version of the input or a newly created one).
    • run_system: Use this only if the task cannot be decomposed into per-molecule operations (e.g., operations that require knowledge of the entire system context). This method receives a System object, which is modified in place.
    from vermouth.processors.processor import Processor
    
    class MyCustomProcessor(Processor):
        def run_molecule(self, molecule):
            # Modify the molecule or create a new one
            # Must return a Molecule object
            return molecule
    
    # OR
    
    class MySystemWideProcessor(Processor):
        def run_system(self, system):
            # Modify the system in place
            pass