Skip to content

Commit

Permalink
doc string upgrades in analysis.contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
orbeckst authored and backpropper committed Mar 13, 2016
1 parent e0fe584 commit 92e6615
Showing 1 changed file with 67 additions and 2 deletions.
69 changes: 67 additions & 2 deletions package/MDAnalysis/analysis/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,6 @@ def __init__(self, *args, **kwargs):
# - select contact pairs to write out as a timecourse
# - make this selection based on qavg
from os.path import splitext

warnings.warn("ContactAnalysis1 is deprecated and will be removed in 1.0/. Use Contacts instead.", DeprecationWarning)

warnings.warn("ContactAnalysis1 is deprecated and will be removed in 1.0. "
"Use Contacts instead.", category=DeprecationWarning)
Expand Down Expand Up @@ -1072,6 +1070,7 @@ def _conclude(self):
for frame, q1, n1 in self.timeseries:
f.write("{frame:4d} {q1:8.6f} {n1:5d}\n".format(**vars()))

<<<<<<< 0b318502a33fc222a7621937cfc96541788ce84d
def contact_matrix(self, d, out=None):
"""Return distance array with True for contacts.
Expand All @@ -1094,6 +1093,31 @@ def contact_matrix(self, d, out=None):
Note
----
This method is typically only used internally.
=======
def qarray(self, d, out=None):
"""Return array with ``True`` for contacts.

Note
----
This method is typically only used internally.

Arguments
---------
d : array
2D array of distances. The method uses the value of
:attr:`radius` to determine if a ``distance < radius``
is considered a contact.
out : array, optional
If `out` is supplied as a pre-allocated array of the correct
shape then it is filled instead of allocating a new one in
order to increase performance.

Returns
-------
array
contact matrix

>>>>>>> doc string upgrades in analysis.contacts
"""
if out:
out[:] = (d <= self.radius)
Expand All @@ -1104,6 +1128,7 @@ def contact_matrix(self, d, out=None):
def fraction_native(q, out=None):
"""Calculate native contacts relative to reference state.

<<<<<<< 0b318502a33fc222a7621937cfc96541788ce84d
Parameters
----------
q: array
Expand All @@ -1123,6 +1148,29 @@ def fraction_native(q, out=None):
Note
----
This method is typically only used internally.
=======
Note
----
This method is typically only used internally.

Arguments
---------
q : array
contact matrix (see :meth:`Contacts.qarray`)
out : array, optional
If `out` is supplied as a pre-allocated array of the correct
shape then it will contain the contact matrix relative
to the reference state, i.e. only those contacts that
are also seen in the reference state.

Returns
-------
contacts : integer
total number of contacts
fraction : float
fraction of contacts relative to the reference state

>>>>>>> doc string upgrades in analysis.contacts
"""
if out:
np.logical_and(q, self.mask, out)
Expand All @@ -1132,6 +1180,7 @@ def fraction_native(q, out=None):
return contacts, float(contacts) / self.mask.sum()
def plot(self, filename=None, **kwargs):
<<<<<<< 0b318502a33fc222a7621937cfc96541788ce84d
"""Plot q(t).

Parameters
Expand Down Expand Up @@ -1163,6 +1212,7 @@ def plot(self, filename=None, **kwargs):
fig.show()
def plot_qavg(self, filename=None, **kwargs):
<<<<<<< 0b318502a33fc222a7621937cfc96541788ce84d
"""Plot `Contacts.qavg`, the matrix of average contacts.

Parameters
Expand All @@ -1173,6 +1223,21 @@ def plot_qavg(self, filename=None, **kwargs):
keyword arguments are passed on to `pylab.imshow`.
**kwargs
Arbitrary keyword arguments for the plotting function
=======
"""Plot the matrix of average contacts.
Convenience function to plot :attr:`qavg`.
Arguments
---------
filename : string, optional
If `filename` is supplied then the figure is also written
to file (the suffix determines the file type, e.g. pdf,
png, eps, ...).
**kwargs
All other keyword arguments are passed on to
:func:`matplotlib.pyplot.imshow`.
>>>>>>> doc string upgrades in analysis.contacts
"""
if not self.contact_matrix :
raise ValueError("No timeseries data; do 'Contacts.run()' first.")
Expand Down

0 comments on commit 92e6615

Please sign in to comment.