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

Deprecate ContactMap (allowing rename ContactFrequency => ContactMap) #84

Merged
merged 2 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 29 additions & 1 deletion contact_map/contact_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import itertools
import pickle
import json

import warnings

sroet marked this conversation as resolved.
Show resolved Hide resolved
import numpy as np
import pandas as pd
import mdtraj as md
Expand Down Expand Up @@ -675,13 +678,25 @@ def residue_contacts(self):
class ContactMap(ContactObject):
"""
Contact map (atomic and residue) for a single frame.

.. deprecated:: 0.6.0
``ContactMap`` will be removed in Contact Map Explorer 0.7.0 because
it is redundant with ``ContactFrequency``. For more, see
https://github.com/dwhswenson/contact_map/issues/82.

"""
# Default for use_atom_slice, None tries to be smart
_class_use_atom_slice = None

_deprecation_message=(
"The ContactMap class will be removed in Contact Map Explorer 0.7. "
+ "Use ContactFrequency instead. For more, see: "
+ "https://github.com/dwhswenson/contact_map/issues/82."
)

def __init__(self, frame, query=None, haystack=None, cutoff=0.45,
n_neighbors_ignored=2):

warnings.warn(self._deprecation_message, FutureWarning)
self._frame = frame # TODO: remove this?
super(ContactMap, self).__init__(frame.topology, query, haystack,
cutoff, n_neighbors_ignored)
Expand All @@ -692,6 +707,19 @@ def __init__(self, frame, query=None, haystack=None, cutoff=0.45,
(atom_contacts, self._residue_contacts) = contact_maps
self._atom_contacts = self.convert_atom_contacts(atom_contacts)

@classmethod
def from_dict(cls, dct):
warnings.warn(cls._deprecation_message, FutureWarning)
return super(ContactMap, cls).from_dict(dct)

# don't need to add deprecation in from_json because it uses from_dict

@classmethod
def from_file(cls, filename):
warnings.warn(cls._deprecation_message, FutureWarning)
return super(ContactMap, cls).from_file(filename)


def __hash__(self):
return hash((super(ContactMap, self).__hash__(),
tuple(self._atom_contacts.items()),
Expand Down
42 changes: 42 additions & 0 deletions examples/concurrences.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,48 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
Expand Down
Loading