msmbuilder / msmbuilder-legacy

Legacy release of MSMBuilder
http://msmbuilder.org
GNU General Public License v2.0
25 stars 28 forks source link

bugfix in contact metric #421

Closed schwancr closed 10 years ago

schwancr commented 10 years ago

The contact metric uses mdtraj.compute_contacts, but that method returns both the distances as well as the contacts used. So, prepare_trajectory needs to only select the first element.

schwancr commented 10 years ago

This means, of course, that we should really add a test that uses the continuouscontact metric.

schwancr commented 10 years ago

Actually, we should really add tests for all of the metrics ... let's save that for a different PR since it will be a bigger issue, and right now we need a patch for this issue.

schwancr commented 10 years ago

See https://github.com/rmcgibbo/mdtraj/blob/master/MDTraj/geometry/contact.py#L182

schwancr commented 10 years ago

@rmcgibbo or @kyleabeauchamp can one of you make sure I didn't do anything really stupid here so we can merge this?

kyleabeauchamp commented 10 years ago

+1

Here is the driver code I just used to test:

import msmbuilder as msmb
import mdtraj as md
t = md.load("/home/kyleb/src/rmcgibbo/mdtraj/MDTraj/testing/reference/frame0.h5")

c = msmb.metrics.contact.BooleanContact(contacts=np.array([[0,1]]))
d = c.prepare_trajectory(t)
d.shape

c = msmb.metrics.contact.ContinuousContact(contacts=np.array([[0,1]]))
d = c.prepare_trajectory(t)
d.shape

The old code raises AttributeErrors, the new code gives (500, 1)...