-
Notifications
You must be signed in to change notification settings - Fork 663
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
Fix HydrogenBondAnalysis when no atom pair is with 3A #1325
Changes from 9 commits
53e1d94
b1f71e1
dff9ad1
b6a8a07
c1d3eef
0f89262
65536ea
98aba1f
cc947a4
a44bbc5
a9b238d
120f380
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,12 @@ | |
|
||
import itertools | ||
import warnings | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
from BytesIO import BytesIO | ||
except ImportError: | ||
from io import BytesIO | ||
|
||
from MDAnalysisTests.datafiles import PDB_helix, GRO, XTC | ||
from MDAnalysisTests.datafiles import PDB_helix, GRO, XTC, HBond_atoms_far | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove HBond_atoms_far |
||
# For type guessing: | ||
from MDAnalysis.topology.core import guess_atom_type | ||
from MDAnalysis.core.topologyattrs import Atomtypes | ||
|
@@ -88,6 +92,18 @@ def test_generate_table(self): | |
assert_array_equal(h.table.acceptor_resnm, self.values['acceptor_resnm']) | ||
|
||
@staticmethod | ||
def test_atoms_too_far(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor thing: Make this a static method @staticmethod
def test_atoms_too_far():
... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
pdb = '''TITLE Two atoms far away | ||
CRYST1 52.763 52.763 52.763 90.00 90.00 90.00 P 1 1 | ||
MODEL 1 | ||
ATOM 1 N LEU 1 32.310 13.778 14.372 1.00 0.00 SYST N 0 | ||
ATOM 2 OW SOL 2 3.024 4.456 4.147 1.00 0.00 SYST H 0''' | ||
|
||
u = MDAnalysis.Universe(BytesIO(pdb.encode()), format="pdb") | ||
h = MDAnalysis.analysis.hbonds.HydrogenBondAnalysis(u, 'resname SOL', 'protein') | ||
h.run(verbose=False) | ||
assert_equal(h.timeseries, [[]]) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There has to be a @staticmethod in front of the test_true_traj() function; Travis fails https://travis-ci.org/MDAnalysis/mdanalysis/jobs/227170225 , too, and QC flags it as a critical issue. |
||
def test_true_traj(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
u = MDAnalysis.Universe(GRO, XTC) | ||
u.add_TopologyAttr(guess_types(u.atoms.names)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
TITLE Two atoms far away | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove (you're using the inline test) |
||
CRYST1 52.763 52.763 52.763 90.00 90.00 90.00 P 1 1 | ||
MODEL 1 | ||
ATOM 1 N LEU 1 32.310 13.778 14.372 1.00 0.00 SYST N 0 | ||
ATOM 2 OW SOL 2 3.024 4.456 4.147 1.00 0.00 SYST H 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,7 @@ | |
"MMTF", "MMTF_gz", | ||
"ALIGN_BOUND", # two component bound system | ||
"ALIGN_UNBOUND", # two component unbound system | ||
"HBond_atoms_far", # Universe with two atoms far away | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove (you're using the inline test) |
||
] | ||
|
||
from pkg_resources import resource_filename | ||
|
@@ -221,6 +222,7 @@ | |
XTC_sub_sol = resource_filename(__name__, 'data/cobrotoxin.xtc') | ||
PDB_sub_sol = resource_filename(__name__, 'data/cobrotoxin.pdb') | ||
PDB_xlserial = resource_filename(__name__, 'data/xl_serial.pdb') | ||
HBond_atoms_far = resource_filename(__name__, 'data/HBond_atoms_far.pdb') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove (you're using the inline test) |
||
XTC_single_frame = resource_filename( | ||
__name__, 'data/xtc_test_only_single_frame_10_atoms.xtc') | ||
XTC_multi_frame = resource_filename( | ||
|
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.
Why is this needed?? I think it can be removed, can't it?
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.
Thank you for your comment. There is no StringIO in py3 so I was trying to make it compatible with py3. I still need some time to figure out how this stream reading works.
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.
Oh, I didn't think about this. Then we should probably use six.StringIO: something like
which replaces
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.
Thank you. It seems that six is more powerful than I thought after spending an hour playing with py3.io.StringIO.