-
Notifications
You must be signed in to change notification settings - Fork 652
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
Port GRO tests to new BaseReader/Writer Test classes #1196
Conversation
@jbarnoud When I ran the |
I do not see why the frames were numbered from 0, and are now numbered from 1. After a quick glance at the code, I would have expected them to be numbered from 0; yet, I am not super up to date with the readers. Maybe @kain88-de has an idea? |
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.
The start looks good. But GRO files are an special in that they only store a single snapshot. This means our base test will have to be adopted for such a format.
@@ -6,28 +6,28 @@ frame 0 | |||
CA 9.00000 10.00000 11.00000 | |||
CA 12.00000 13.00000 14.00000 | |||
5 | |||
frame 0 | |||
frame 1 |
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.
This looks like we fixed something in the xyz writer since we created these files.
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.
Please also create a new zipped file for the xyz format based on this. The readme says how this is done.
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.
this file should be removed too
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
import numpy as np | ||
|
||
|
||
class GROReference(BaseReference): |
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.
they should be included in the main gro test file.
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.
Yes, I just wanted to keep it separate while I'm working on it so it don't get it mixed. Once I'm done I'll move it to its correct place.
3ILE CA 3 9.600 11.200 12.800 0.9600 1.1200 1.2800 | ||
4LYS CA 4 14.400 16.000 17.600 1.4400 1.6000 1.7600 | ||
5LEU CA 5 19.200 20.800 22.400 1.9200 2.0800 2.2400 | ||
8.51000 8.59223 8.35003 0.00000 0.00000 0.69131 0.00000 1.45589 2.09054 |
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.
This looks like it's only the last frame. But according to the docs GRO can only write one frame per file. Multiple frames are stored in multiple files. So the trajectory in gro files can only be read with the chain-reader (that works and it tested separately no need to test the chain reader in this PR)
@@ -0,0 +1,8 @@ | |||
Written by MDAnalysis |
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.
This header line should include a time t =
as mentioned in the gromacs docs.
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.
This will be an issue with the GROWriter then?
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.
t
is optional according to docs
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.
Yes but we have that information so we should provide it.
self.ext = 'gro' | ||
# self.volume = 0 | ||
# self.dimensions = np.zeros(6) | ||
# self.container_format = True |
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 need to deactivate all tests that skip frames or otherwise work on the assumption that a gro stores a trajectory instead of a single snapshot. For this you need to change the BaseReaderTest.
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.
@kain88-de I looked into how tests are skipped and I came across the skipif
decorator that we import from numpy
. But then to check the ext
attribute I'd have to use self
which I can't. I mean I can't do something like:
@dec.skipif(self.ext == 'gro')
Is there a workaround for this? Or should I fall back to vanilla if/else statements in methods?
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.
General comment. The general purpose BaseReaderTest shouldn't know anything about the specific extensions used. You should enable/disable tests based on values in the reference.
Why doesn't the skipif work?
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.
@kain88-de It doesn't work because there isn't any reference to self
.
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.
It's probably best to make BaseReaderTest
a subclass of a base class for single frame readers? The TRR readers etc do everything that GROReader does, with some extra features (traj iteration)
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.
So the base class has what a GROReader should have. BaseReaderTest should then inherit from it and add functionality for TRR
etc. that have multiple frames? Or maybe we could have a multiple frame mixin 🤔
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.
@utkbansal yeah so something like
class BaseReaderTest(object):
# define what ALL readers should do
class MultiframeReaderTest(BaseReaderTest):
# define what extra a multiframe reader does
So the current existing BaseReaderTest
is actually a mix of two sets of tests imo
@@ -0,0 +1,8 @@ | |||
Written by MDAnalysis | |||
5 | |||
1MET CA 1 0.000 1.600 3.200 0.0000 0.1600 0.3200 |
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.
The last 3 values are the velocities. You should also check that they are activated in the tests
b4d818b
to
f882a29
Compare
@kain88-de Can you have a look at the travis build errors. I don't understand the errors. Though there are errors in the code, but the traceback is different. |
lets see what happens when we restart the build |
@kain88-de Same error The only reference to our code is at |
The traceback is because of my nose plugin that look at open files. My last "fix" on it obviously made it more fragile. I'll deactivate it from travis. |
@jbarnoud @kain88-de Thanks! the flag eg,
Here the value |
Hey, this is good work. I think the problem here is that the Gro file is the last frame (it gets overwritten repeatedly until the last frame). So the reference is correct, just the write method which creates the test Gro file should only write the first frame. |
@richardjgowers Okay. So I will have to modify the |
Yes
…On Sat, 4 Feb 2017, 11:18 a.m. Utkarsh Bansal, ***@***.***> wrote:
@richardjgowers <https://github.com/richardjgowers> Okay. So I will have
to modify the create_data.py script to output only the first frame in
case of gro, right?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1196 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI0jBw8N1jazX2z36AsO5ZYeeooktM3mks5rZF6IgaJpZM4L2B2S>
.
|
@kain88-de @richardjgowers I have updated the gro file. Can you confirm if this is the first frame? |
In the last commit I added velocities to the |
@utkbansal It looks like you need to patch the GroWriter since it isn't following the standard right now. You will also have to split the Writer tests into a BaseWriter and MultiFrameWriter tests. |
@kain88-de You mean the |
yes
@jbarnoud you know most about the aux reader |
|
3ad9ff2
to
71ce217
Compare
@jbarnoud @kain88-de Regarding |
77c6aea
to
26e1b4c
Compare
@kain88-de I don't see any frame skipping stuff in |
@utkbansal the writer tests often writes multi frame trajectories. The GRO format doesn't allow to write multiple frames into one file. So the Writer tests should only check that the one frame it can write is written correctly. |
@kain88-de @richardjgowers I have added all the tests required for the Regarding tests for |
@kain88-de @richardjgowers @jbarnoud I need help with this please. |
@@ -1747,7 +1747,7 @@ class SingleFrameReader(ProtoReader): | |||
""" | |||
_err = "{0} only contains a single frame" | |||
|
|||
def __init__(self, filename, convert_units=None, **kwargs): | |||
def __init__(self, filename, convert_units=None, n_atoms=None, **kwargs): |
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 did you make this change?
@@ -6,28 +6,28 @@ frame 0 | |||
CA 9.00000 10.00000 11.00000 | |||
CA 12.00000 13.00000 14.00000 | |||
5 | |||
frame 0 | |||
frame 1 |
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.
Please also create a new zipped file for the xyz format based on this. The readme says how this is done.
The GROWriter currently doesn't follow the standard API that we have. So you will need to change that one to accept and work with a Timestep, AtomGroup, or a Universe. The Writing a Universe or AtomGroup you should be able to use the current code. For the Timestep you have to make sure that valid names and resnames exist. The standard for unknown atom name is |
* Use .copy() method to use new copies instead of references
38f631f
to
1a3f81f
Compare
@kain88-de @richardjgowers I have done a rebase and force push. |
LGTM assuming tests pass |
@utkbansal thanks for doing this all the way to the end |
I should be the one thanking you all 😄 Without help from all of you I wouldn't be able to do this. |
Fixes part of #516
Changes made in this Pull Request:
GROWriter
to conform to the Reader API standard (works withUniverse
,Timestep
&AtomGroup
).BaseReaderTest
intoBaseReaderTest
andMultiframeReaderTest
for single frame & multi frame readers.PR Checklist