contact_map.DaskContactFrequency¶
-
class
contact_map.
DaskContactFrequency
(client, filename, query=None, haystack=None, cutoff=0.45, n_neighbors_ignored=2, **kwargs)[source]¶ Dask-based parallelization of contact frequency.
The contact frequency is the fraction of a trajectory that a contact is made. See
ContactFrequency
for details. This implementation parallelizes the contact frequency calculation usingdask.distributed
, which must be installed separately to use this object.Notes
The interface for this object closely mimics that of the
ContactFrequency
object, with the addition requiring thedask.distributed.Client
as input. However, there is one important difference. WhereasContactFrequency
takes anmdtraj.Trajectory
object as input,DaskContactFrequency
takes a file name, plus any extra kwargs that MDTraj needs to load the file.Parameters: - client (dask.distributed.Client) – Client object connected to the dask network.
- filename (str) – Name of the file where the trajectory is located. File must be accessible by all workers in the dask network.
- query (list of int) – Indices of the atoms to be included as query. Default
None
means all atoms. - haystack (list of int) – Indices of the atoms to be included as haystack. Default
None
means all atoms. - cutoff (float) – Cutoff distance for contacts, in nanometers. Default 0.45.
- n_neighbors_ignored (int) – Number of neighboring residues (in the same chain) to ignore. Default 2.
-
__init__
(client, filename, query=None, haystack=None, cutoff=0.45, n_neighbors_ignored=2, **kwargs)[source]¶
Methods
__init__
(client, filename[, query, …])add_contact_frequency
(other)Add results from other to the internal counter. contact_map
(trajectory, frame_number, …)Returns atom and residue contact maps for the given frame. from_dict
(dct)Create object from dict. from_file
(filename)Load this object from a given file from_json
(json_string)Create object from JSON string most_common_atoms_for_contact
(contact_pair)Most common atom contacts for a given residue contact pair most_common_atoms_for_residue
(residue)Most common atom contact pairs for contacts with the given residue save_to_file
(filename[, mode])Save this object to the given file. subtract_contact_frequency
(other)Subtracts results from other from internal counter. to_dict
()to_json
()JSON-serialized version of this object. -
add_contact_frequency
(other)¶ Add results from other to the internal counter.
Parameters: other ( ContactFrequency
) – contact frequency made from the frames to remove from this contact frequency
-
atom_contacts
¶ Atoms pairs mapped to fraction of trajectory with that contact
-
contact_map
(trajectory, frame_number, residue_query_atom_idxs, residue_ignore_atom_idxs)¶ Returns atom and residue contact maps for the given frame.
Parameters: Returns: - atom_contacts (collections.Counter)
- residue_contact (collections.Counter)
-
cutoff
¶ float – cutoff distance for contacts, in nanometers
-
from_dict
(dct)¶ Create object from dict.
Parameters: dct (dict) – dict-formatted serialization (see to_dict for details) See also
to_dict()
-
from_file
(filename)¶ Load this object from a given file
Parameters: filename (string) – the file to read from Returns: the reloaded object Return type: ContactObject
See also
save_to_file()
- save to a file
-
from_json
(json_string)¶ Create object from JSON string
Parameters: json_string (str) – JSON-serialized version of the object See also
-
haystack
¶ list of int – indices of atoms to include as haystack
-
most_common_atoms_for_contact
(contact_pair)¶ Most common atom contacts for a given residue contact pair
Parameters: contact_pair (length 2 list of Residue or int) – the residue contact pair for which the most common atom contact pairs will be calculated Returns: Atom contact pairs for the residue contact pair, in order of frequency. Referring to the list as l
, each element of the listl[e]
consists of two parts:l[e][0]
is a list containing the two MDTraj Atom objects that make up the contact, andl[e][1]
is the measure of how often the contact occurs.Return type: list
-
most_common_atoms_for_residue
(residue)¶ Most common atom contact pairs for contacts with the given residue
Parameters: residue (Residue or int) – the Residue object or index representing the residue for which the most common atom contact pairs will be calculated Returns: Atom contact pairs involving given residue, order of frequency. Referring to the list as l
, each element of the listl[e]
consists of two parts:l[e][0]
is a list containing the two MDTraj Atom objects that make up the contact, andl[e][1]
is the measure of how often the contact occurs.Return type: list
-
n_frames
¶ Number of frames in the mapped trajectory
-
n_neighbors_ignored
¶ int – number of neighbor residues (in same chain) to ignore
-
query
¶ list of int – indices of atoms to include as query
-
residue_contacts
¶ Residue pairs mapped to fraction of trajectory with that contact
-
residue_ignore_atom_idxs
¶ dict – maps query residue index to atom indices to ignore
-
residue_query_atom_idxs
¶ dict – maps query residue index to atom indices in query
-
save_to_file
(filename, mode='w')¶ Save this object to the given file.
Parameters: - filename (string) – the file to write to
- mode ('w' or 'a') – file writing mode. Use ‘w’ to overwrite, ‘a’ to append. Note that writing by bytes (‘b’ flag) is automatically added.
See also
from_file()
- load from generated file
-
subtract_contact_frequency
(other)¶ Subtracts results from other from internal counter.
Note that this is intended for the case that you’re removing a subtrajectory of the already-calculated trajectory. If you want to compare two different contact frequency maps, use
ContactDifference
.Parameters: other ( ContactFrequency
) – contact frequency made from the frames to remove from this contact frequency
-
to_json
()¶ JSON-serialized version of this object.
See also
-
topology
¶ mdtraj.Topology
– topology object for this systemThe topology includes information about the atoms, how they are grouped into residues, and how the residues are grouped into chains.