Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact trajectories #81

Merged
merged 21 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
558716b
Add from_contacts builder to ContactObjects
dwhswenson Aug 12, 2020
2d9fc25
Tests for from_contacts
dwhswenson Aug 12, 2020
6d12810
most of ContactTrajectory (and related)
dwhswenson Aug 13, 2020
5a11fc2
Merge branch 'master' of github.com:dwhswenson/contact_map into conta…
dwhswenson Aug 13, 2020
d5e5d28
Switch to using coveralls (not python-coveralls)
dwhswenson Aug 13, 2020
9bc0541
First sets of tests for contact trajectories
dwhswenson Aug 13, 2020
d1debcd
progress on MutableContactTraj, traj.contact_freq
dwhswenson Aug 13, 2020
4dcd878
tests for ContactTraj.contact_freq
dwhswenson Aug 14, 2020
2f03c7a
Merge branch 'master' of github.com:dwhswenson/contact_map into conta…
dwhswenson Aug 17, 2020
5c5c6d6
tests for mutable contact trajectory
dwhswenson Aug 28, 2020
2c29511
add support for atom-slicing trajs
dwhswenson Aug 28, 2020
eabea6f
compatibility check in from_contact_maps
dwhswenson Aug 29, 2020
c64b688
Tests for RollingContactFrequency
dwhswenson Aug 31, 2020
4a3c172
docs and docstrings
dwhswenson Aug 31, 2020
fabbac3
Add example
dwhswenson Aug 31, 2020
fca7d97
Update contact_map/contact_trajectory.py
dwhswenson Aug 31, 2020
b6dcd14
Update contact_map/contact_trajectory.py
dwhswenson Aug 31, 2020
17fe913
Update contact_map/contact_trajectory.py
dwhswenson Aug 31, 2020
91cf05c
Update contact_map/tests/test_contact_trajectory.py
dwhswenson Aug 31, 2020
2961713
Update contact_map/tests/test_contact_trajectory.py
dwhswenson Aug 31, 2020
8677682
Update contact_map/contact_trajectory.py
dwhswenson Aug 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contact_map/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from .contact_count import ContactCount

from .contact_trajectory import ContactTrajectory, RollingContactFrequency

from .min_dist import NearestAtoms, MinimumDistanceCounter

from .concurrence import (
Expand Down
33 changes: 33 additions & 0 deletions contact_map/contact_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ def __init__(self, topology, query, haystack, cutoff, n_neighbors_ignored):
}
self._atom_idx_to_residue_idx = self._set_atom_idx_to_residue_idx()

@classmethod
def from_contacts(cls, atom_contacts, residue_contacts, topology,
query=None, haystack=None, cutoff=0.45,
n_neighbors_ignored=2):
obj = cls.__new__(cls)
super(cls, obj).__init__(topology, query, haystack, cutoff,
n_neighbors_ignored)

def get_contact_counter(contact):
if isinstance(contact, ContactCount):
return contact.counter
else:
return contact

obj._atom_contacts = get_contact_counter(atom_contacts)
obj._residue_contacts = get_contact_counter(residue_contacts)
return obj

def _set_atom_slice(self):
""" Set atom slice logic """
if (self._class_use_atom_slice is None and
Expand Down Expand Up @@ -774,6 +792,17 @@ def __init__(self, trajectory, query=None, haystack=None, cutoff=0.45,
contacts = self._build_contact_map(trajectory)
(self._atom_contacts, self._residue_contacts) = contacts

@classmethod
def from_contacts(cls, atom_contacts, residue_contacts, n_frames,
topology, query=None, haystack=None, cutoff=0.45,
n_neighbors_ignored=2):
obj = super(ContactFrequency, cls).from_contacts(
atom_contacts, residue_contacts, topology, query, haystack,
cutoff, n_neighbors_ignored
)
obj._n_frames = n_frames
return obj

def __hash__(self):
return hash((super(ContactFrequency, self).__hash__(),
tuple(self._atom_contacts.items()),
Expand Down Expand Up @@ -951,6 +980,10 @@ def __sub__(self, other):
def contact_map(self, *args, **kwargs): #pylint: disable=W0221
raise NotImplementedError

@classmethod
def from_contacts(self, *args, **kwargs): #pylint: disable=W0221
raise NotImplementedError

@property
def atom_contacts(self):
n_x = self.topology.n_atoms
Expand Down
Loading