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

Improved, Best-like contact analysis (Issue #702) #708

Closed
wants to merge 26 commits into from

Conversation

jandom
Copy link
Contributor

@jandom jandom commented Feb 9, 2016

Addresses #702.

A worked example with GpA dimer in a bilayer

Added tests to the BestHummerContacts calculation

Tests for fraction of native contacts (Q)

A worked example with GpA dimer in a bilayer

Added tests to the BestHummerContacts calculation

Tests for fraction of native contacts (Q)
@@ -146,14 +144,15 @@
import errno
import warnings
import bz2
from six.moves import zip
from itertools import izip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should keep from six.moves import zip

zip here is izip in py2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the six import was correct. It does import the iterator version of zip under python2 as zip. So no more izip. This is part of our effort to support python3 along with python2 in the future.

- removed a dependancy on pandas, update tests
@jandom
Copy link
Contributor Author

jandom commented Feb 10, 2016

Ah, crap - it seems that I applied my changes to some ghetto-old version of contacts.py. This is now changed: the only part of contacts.py that differs from the version in develop branch.

So basically all your comments about contacts.py are valid but to some old version of contacts.py

The only thing that I really added is:

  • class BestHummerContacts(AnalysisBase), object-oriented
  • calculate_contacts, function

step : int, optional
Step between frames to analyse, Default: 1
"""
self.u = u
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to pull the reference to universe off grA to reduce the number of arguments here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, provided that

assert(grA.universe == grB.universe)

I prefer passing groups instead of atom selection string. Whenever i pass a selection string to rms_fit_trj and i cock something up (selections are not identical, etc) i takes an extra step to debug it (gotta create the AtomGroups by hand). Plus people may be constructing AtomGroups by hand in this scenario.

@jandom
Copy link
Contributor Author

jandom commented Feb 10, 2016

@richardjgowers many thanks for all your comments and helping me navigate in the conventions! The tests fail because I use a function that depends on scipy - that used to be a dep of MDAnalysis, what's the replacement now?

======================================================================

ERROR: Failure: ImportError (No module named scipy)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/home/travis/miniconda/envs/pyenv/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName

    addr.filename, addr.module)

  File "/home/travis/miniconda/envs/pyenv/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath

    return self.importFromDir(dir_path, fqname)

  File "/home/travis/miniconda/envs/pyenv/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir

    mod = load_module(part_fqname, fh, filename, desc)

  File "/home/travis/miniconda/envs/pyenv/lib/python2.7/site-packages/MDAnalysisTests/analysis/test_contacts_best.py", line 23, in <module>

    from MDAnalysis.analysis.contacts import BestHummerContacts, calculate_contacts

  File "/home/travis/miniconda/envs/pyenv/lib/python2.7/site-packages/MDAnalysis/analysis/contacts.py", line 859, in <module>

    from MDAnalysis.analysis.distances import distance_array

  File "/home/travis/miniconda/envs/pyenv/lib/python2.7/site-packages/MDAnalysis/analysis/distances.py", line 34, in <module>

    from scipy import sparse

ImportError: No module named scipy```

results: list
Fraction of native contacts for each frame
"""
assert(grA.universe == grB.universe)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want an assert here, do a proper if not x==y: raise ValueError with a nice message

@richardjgowers
Copy link
Member

I think scipy is optional now, not sure there's a workaround for sparse matrices. You can decorate the test in a skipif (grep for another scipy test in analysis), we run 2 lots of tests, minimal and full.

@jandom
Copy link
Contributor Author

jandom commented Feb 10, 2016

Build passes, allelujah!

@orbeckst
Copy link
Member

backlink to #702

@kain88-de
Copy link
Member

Thanks for giving me some time

@jandom
Copy link
Contributor Author

jandom commented Feb 24, 2016

@kain88-de @orbeckst all done here again (I think...) added numpy style docs, reworked the test, fixed the staticmethod problem

- ContactAnalysis was removed by @jandom but needs to
  stay because the functionality does not exist in the
  new Contact class
  (But it needs to be rewritten with AnalysisBase.)
- updated doc strings (numpy style)
@orbeckst
Copy link
Member

@jandom, you have a PR jandom#1 for the remaining stuff.
Note that I put ContactAnalysis back in – it's terribly ugly but that's something for another issue.


logger = logging.getLogger("MDAnalysis.analysis.contacts")


class ContactAnalysis(object):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put ContactAnalysis back in jandom#1 – it should not have been removed. Raise an issue to overhaul ContactAnalysis to work within the new analysis model. We can then also rename it and break it's API, or for all I care, completely rewrite with more focused functionality. But for right now it has to stay.

@orbeckst
Copy link
Member

@jandom , add an entry to CHANGELOG!

@jandom
Copy link
Contributor Author

jandom commented Feb 25, 2016

Aye, no problem adding back ContactAnalysis - will update the CHANGELOG

@orbeckst
Copy link
Member

@jandom, did you merge my PR?

self.outfile = outfile

@staticmethod
def load(filename):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method uses self, it cannot be a static method.

@orbeckst
Copy link
Member

This looks done to me. I added the WIP flag so that it doesn't get merged for 0.14.x (as discussed with @kain88-de ).

That was a long process but along the way we made big strides towards a better analysis module #719 . Many thanks to @jandom and everyone else involved in the discussion.

kain88-de pushed a commit that referenced this pull request Feb 29, 2016
- numpy style docs
- guard scipy.sparse import and warn
- see PR #708 for discussion
@kain88-de
Copy link
Member

I merged it by hand see 4ee46b.

@kain88-de kain88-de closed this Feb 29, 2016
@jandom
Copy link
Contributor Author

jandom commented Feb 29, 2016

@kain88-de ditto #702 :)

@orbeckst
Copy link
Member

If this is now on develop then the current develop will have to become 0.15.0. If we want a 0.14.1 then we need to branch from before this merge.

With semantic versioning we can't have new features in a patch release.

Oliver Beckstein
email: orbeckst@gmail.com

Am Feb 29, 2016 um 1:34 schrieb kain88-de notifications@github.com:

I merged it by hand see 4ee46b.


Reply to this email directly or view it on GitHub.

@kain88-de
Copy link
Member

There isn't much for the patch release. We should be able to cherry-pick them into a release-0.14.1 branch. Besides I'm good with just cutting a new release every 1-2 months. That is very predictable for me and enough time to get 1 or 2 bigger things merged.

@kain88-de
Copy link
Member

I've started working on improvements of the new Contacts class, you can have a look here.

I want to add some additional examples and documentation to the module. For this it would be nice to know what other people want to use the contact analysis for.

Use Cases

  • native contacts for folding
  • native contacts relative to two conformations ("q1-q2") for tracking conformational transitions (see Fig 7A in @sseyler 's PSA paper)
  • contacts in a binding pocket between two proteins
  • I read something about centroid with membrane sidechains

It would be nice if others contribute as well what this type of analysis can be used for. That way I can write examples and add tests for all of them (hopefully).

History

  • 2016-03-02: added q1-q2 as example — @orbeckst

@orbeckst
Copy link
Member

orbeckst commented Mar 2, 2016

Actually, let's have this discussion in a new issue!

backpropper pushed a commit to backpropper/mdanalysis that referenced this pull request Mar 13, 2016
- numpy style docs
- guard scipy.sparse import and warn
- see PR MDAnalysis#708 for discussion
@kain88-de kain88-de mentioned this pull request Mar 20, 2016
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants