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
Implements Py3-compatible rich comparison for all Bio.PDB objects #1360
Conversation
…RA objects. Special rules for Chains, Residues, and Atoms
… object sorting. Edited other tests to comply with changes.
Bio/PDB/Residue.py
Outdated
|
||
self.child_list.sort(key=sort_index) | ||
|
||
self.child_list.sort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that not be self.child_list.sort()
for an in-place sorting of the list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted!
Is it worth adding public |
Are you happy with running
After that it will run |
I would actually propose removing them altogether and have people use the
Yes. I'll do that. I had a linter plugin for Atom (the editor) but that kept leaving Python processes hanging after I closed the program (100% CPU for hours...). I'll run locally. Do we have a pre-commit hook for this somewhere? Would be nice to have at hand... |
Bio/PDB/Residue.py
Outdated
return (i, atom.name, atom.altloc) | ||
|
||
self.child_list.sort(key=sort_index) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to remove this blank link to make flake8
happy:
$ flake8 Bio/
Bio/PDB/Residue.py:92:1: D202 No blank lines allowed after function docstring
I would vote for that. |
@etal @peterjc Some tests are failing on Py 3.4 and made me realize I might have misunderstood how to write these methods. For example, for an Edit: Added a test for |
…or Py2/Py3 behaviors
Codecov Report
@@ Coverage Diff @@
## master #1360 +/- ##
==========================================
- Coverage 84.48% 84.36% -0.13%
==========================================
Files 319 319
Lines 48920 49100 +180
==========================================
+ Hits 41332 41423 +91
- Misses 7588 7677 +89
Continue to review full report at Codecov.
|
Bio/PDB/Residue.py
Outdated
@@ -108,6 +108,10 @@ def sort(self): | |||
by name, with any alternative location specifier for disordered | |||
atoms (altloc) as a tie-breaker. | |||
""" | |||
warnings.warn("The custom sort() method will be deprecated in the " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "deprecated" to "removed" (or change the tense to "... has been deprecated in favour of...")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
The coverage is decreasing because of all the rich comparison methods, which have a few conditionals in there, but the testing is actually more extensive than before. If others agree with these changes, we should merge this. |
See preceeding commits from pull request #1360 [ci skip]
See preceeding commits from pull request biopython#1360 [ci skip]
This pull request addresses issue #1356 and refactors #1189 and PR #1291. It implements rich comparisons for every object of the SMCRA hierarchy, including disordered wrappers. This allows direct comparison of any two objects and allows calling the
sorted
method directly, unifying the API.The test suite was expanded and refactored to test all these possibilities. The
a_structure.pdb
test PDB was slightly tweaked to avoid adding yet another file. I had to fix a number of other tests to accomodate these changes. All tests pass under Python 2.7 and Python 3.Thanks @harryjubb for raising the problem that led to this fix, and @peterjc for the earlier work and usual leadership 👍
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I am happy to be thanked by name in the
NEWS.rst
andCONTRIB.rst
files.I have read the
CONTRIBUTING.rst
file and understand that AppVeyor andTravisCI will be used to confirm the Biopython unit tests and
flake8
stylechecks pass with these changes.