contacts

Create contact maps between two atom groups.

This module provides the MapContacts class, which creates the initial contact map between the two atom groups using a maximum cutoff (max_cutoff), which provides for quicker processing if creating results for multiple cutoffs. The ProcessContacts class takes the initial contact map and creates the processed contact map based on the prescribed cutoff.

class contacts.CombineContacts(contact_files, output_name='combined_contacts.pkl', validate_compatibility=True)[source]

Class to combine contact timeseries from multiple repeat runs.

This class enables pooling data from multiple trajectory repeats and calculating posteriors from all data together, rather than analyzing each run separately.

Parameters:
  • contact_files (list of str) – List of contact pickle files to combine

  • output_name (str, optional) – Name for the combined output file (default: ‘combined_contacts.pkl’)

  • validate_compatibility (bool, optional) – Whether to validate that files are compatible (default: True)

run()[source]

Combine contact files and save the result.

class contacts.MapContacts(u, ag1, ag2, nproc=1, frames=None, max_cutoff=10.0, nslices=100)[source]

This class is used to create the map of contacts between two groups of atoms. A single cutoff is used to define a contact between the two groups, where if any atomic distance between the two groups is less than the cutoff, a contact is considered formed.

Parameters:
  • u (MDAnalysis Universe) – Universe containing the topology and trajectory for which the contacts will be computed.

  • ag1 (MDAnalysis AtomGroup) – Primary AtomGroup for which contacts will be computed, typically a protein.

  • ag2 (MDAnalysis AtomGroup) – Secondary AtomGroup which forms contacts with ag1, typically lipids, ions, or other small molecules. Each residue of ag2 must have the same number of atoms.

  • nproc (int, optional) – Number of processes to use in computing contacts (default is 1).

  • frames (list or np.array, optional) – List of frames to use in computing contacts (default is None, meaning all frames are used).

  • max_cutoff (float, optional) – Maximum cutoff to use in computing contacts. A primary contact map is created upon which multiple cutoffs can be imposed, i.e. in the case where a proper cutoff is being determined. This can typically be left at its default value, unless a greater value is needed (default is 10.0).

  • nslices (int, optional) – Number of slices to break the trajectory into for processing. If device memory is limited, try increasing nslices (default is 100).

run()[source]

Run contact analysis and save to contacts_max{max_cutoff}.pkl

class contacts.ProcessContacts(cutoff, map_name, nproc=1)[source]

The ProcessProtein class takes the primary contact map (i.e. contacts_max10.0.pkl) and collects contacts based on a prescribed cutoff.

Parameters:
  • cutoff (float) – Collect all contacts between ag1 and ag2 within this value.

  • map_name (str) – Name of primary contact map. The default produced by MapContacts is contacts_max10.0.pkl.

  • nproc (int, optional) – Number of processes to use in collecting contacts (default is 1).

run()[source]

Process contacts using the prescribed cutoff and write to contacts-{cutoff}.pkl

contacts.get_parser()[source]
contacts.main()[source]