Skip to content

🧬 helanal refactor 🧬#2622

Merged
fiona-naughton merged 18 commits intoMDAnalysis:developfrom
lilyminium:helanal
Jul 19, 2020
Merged

🧬 helanal refactor 🧬#2622
fiona-naughton merged 18 commits intoMDAnalysis:developfrom
lilyminium:helanal

Conversation

@lilyminium
Copy link
Member

@lilyminium lilyminium commented Mar 13, 2020

Fixes #2452

Changes made in this Pull Request:

  • Refactored HELANAL to use AnalysisBase

Well, it produces the same numbers as the old helanal. Changed the algorithm for calculating screw angles. A few things left (which the old module didn't implement):

  • fit a sphere and classify the helix as linear or curved

The local helix origins are reoriented
in X-Y plane and the reoriented points are used to fit a circle as well as a
line, by least squares method. Based on the relative goodness of line and
circle fit to local helix origins, the helix is classified as being linear or
curved
.

  • classify helix as kinked or not

A helix is classified as being kinked, if at least one local bending
angle in the middle of the helix is greater than 20 degrees.

Demo notebook here. It also has pictures of the attributes, I would appreciate feedback on if they make it clear what HELANAL actually calculates.

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@lilyminium
Copy link
Member Author

@wg150 @fiona-naughton I would love your thoughts on this as it is now and anything you would add!

@codecov
Copy link

codecov bot commented Mar 13, 2020

Codecov Report

Merging #2622 into develop will decrease coverage by 0.43%.
The diff coverage is 97.57%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2622      +/-   ##
===========================================
- Coverage    92.67%   92.23%   -0.44%     
===========================================
  Files          184      185       +1     
  Lines        24057    24300     +243     
  Branches      3102     3148      +46     
===========================================
+ Hits         22294    22413     +119     
- Misses        1717     1822     +105     
- Partials        46       65      +19     
Impacted Files Coverage Δ
package/MDAnalysis/analysis/helix_analysis.py 97.33% <97.33%> (ø)
package/MDAnalysis/analysis/helanal.py 90.54% <100.00%> (+0.08%) ⬆️
package/MDAnalysis/lib/mdamath.py 100.00% <100.00%> (ø)
package/MDAnalysis/lib/util.py 88.71% <100.00%> (+0.03%) ⬆️
package/MDAnalysis/topology/tpr/utils.py 80.76% <0.00%> (-16.18%) ⬇️
package/MDAnalysis/due.py 61.11% <0.00%> (-13.89%) ⬇️
package/MDAnalysis/coordinates/chemfiles.py 88.34% <0.00%> (-6.14%) ⬇️
package/MDAnalysis/coordinates/ParmEd.py 83.33% <0.00%> (-3.45%) ⬇️
package/MDAnalysis/topology/TPRParser.py 93.84% <0.00%> (-1.32%) ⬇️
package/MDAnalysis/analysis/hole2/utils.py 74.84% <0.00%> (-1.26%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40a8c95...bbe290b. Read the comment docs.

@richardjgowers
Copy link
Member

This looks like good code, but someone who actually knows the science ought to review it

@lilyminium
Copy link
Member Author

Hm, ok, something to fix here. (x-axis is time)

Screenshot 2020-03-17 at 7 09 43 AM

@richardjgowers
Copy link
Member

richardjgowers commented Mar 16, 2020 via email

@lilyminium
Copy link
Member Author

These are already preprocessed and unwrapped -- I think the 30 degrees is swinging around to 150 because I'm only calculating the angle from one direction. But yes I should put in PBC

@lilyminium
Copy link
Member Author

lilyminium commented Mar 16, 2020

I'm going to have to come up with better tests than just comparing to old helanal's output...
image

Is this what local_screw is actually meant to be? I couldn't find this in the paper.
image

Edit: x-axis is now residue.

image

Should local_bends should stay in the pi/2, -pi/2 domain?

Copy link
Contributor

@fiona-naughton fiona-naughton left a comment

Choose a reason for hiding this comment

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

Looks good! I think you've pretty much covered all the major changes I wanted to see :) I've added a couple comments; several of them are particularly related to the algorithm/geometry involved which I'm not 100% sure I followed completely, so do ignore me if I'm wrong.

A couple more comments on the notebook I think might make things clearer:

  • On the first figure, it's perhaps not immediately clear what plane each the left and right are drawn in. I assume this is what the local_axes are trying to show, but it took me a bit to realise that it's coming out of the page on the left rather than some kind of radial vector. Maybe have a picture of a helix on the side with the planes slicing through it, or something?
  • The second/third figures might also benefit from showing a helix, just to make it clearer at a glance which arrows correspond to what
  • Could show the screw angles/rotation vectors on the third figure

@fiona-naughton
Copy link
Contributor

Re: tests/testing data - those plots do look a little suspicious, though I'm not immediately sure what exactly would be the issue. What input were you using? Doesn't look like the right number of residues for the one the tests use.

Also, might be worth adding a test for when a different ref_axis is selected? There was a bug in the old helanal I never got around to properly reporting where it ignored ref_axis for some calculations and just used the z-axis instead - as far as I can tell this should be fine with the new code, though!

@lilyminium
Copy link
Member Author

Thanks for the review @fiona-naughton! You brought up many of the things I wondered about myself. The inputs are helices from my own trajectories (this refactor was borne out of necessity) but I can put some graphs together from the test data.

Also, might be worth adding a test for when a different ref_axis is selected

Good idea, I think in general the module needs more tests than the old one had.

@lilyminium lilyminium force-pushed the helanal branch 2 times, most recently from af183fb to b9926aa Compare April 12, 2020 06:59
@orbeckst orbeckst changed the title 🧬[WIP] helenal refactor 🧬 🧬helanal refactor 🧬 Jun 5, 2020
Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

TODO: Deprecate the old helanal module.

@pep8speaks
Copy link

pep8speaks commented Jul 6, 2020

Hello @lilyminium! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-07-19 00:53:39 UTC

@fiona-naughton
Copy link
Contributor

Sorry for another delay - looks good to me! (though I see one of the travis jobs has failed, but I don't know enough to know what's gone wrong there...)

@lilyminium
Copy link
Member Author

Thank you @fiona-naughton!!! Thank you for getting through this 😁 😁 😁 Travis was failing on some double RDF docs, I've fixed that now.

@orbeckst
Copy link
Member

orbeckst commented Jul 12, 2020

@fiona-naughton can you please squash-merge this and rewrite the commit message using the information from the PR? Please include the "Fixes" line, and clean up the commit message lines that come from the individual commits. (E.g., leave out any "fixed pep8", "now finally got X working" and all other "PR internal stuff".) The guiding principle is simply that this single commit message should have all the relevant information for the whole thing. Thanks!

Well done, I am glad that this PR finally sees the light of day!

EDIT: added a few please and thank yous... sorry, it's late

@orbeckst
Copy link
Member

@lilyminium can you please

  • make another PR in which you remove old helanal, targeted to milestone 2.0.
  • make a PR against master to add the deprecation notice to old helanal & CHANGELOG (and target to milestone 1.0.x)

Thank you!

@fiona-naughton fiona-naughton merged commit d084bd6 into MDAnalysis:develop Jul 19, 2020
@lilyminium lilyminium deleted the helanal branch July 19, 2020 02:44
@lilyminium lilyminium mentioned this pull request Sep 2, 2020
orbeckst pushed a commit that referenced this pull request Sep 4, 2020
* deprecate helanal, to be removed in 2.0.0 (use analysis.helix_analysis in 2.0 from PR #2622)
* add deprecation warnings to analysis.helanal
* update CHANGELOG
orbeckst pushed a commit that referenced this pull request Sep 4, 2020
* deprecate helanal, to be removed in 2.0.0 (use analysis.helix_analysis in 2.0 from PR #2622)
* add deprecation warnings to analysis.helanal
* update CHANGELOG
PicoCentauri pushed a commit to PicoCentauri/mdanalysis that referenced this pull request Mar 30, 2021
Fixes MDAnalysis#2452 

* added new helanal using AnalysisBase
* deprecated old helanal
* added universe_from_origin
* updated to use np clip
* added new local_screw algorithm
* changed screw angles to projection onto cross-axis
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.

update helanal to AnalysisBase

6 participants