dimchris / mdanalysis

Automatically exported from code.google.com/p/mdanalysis
0 stars 0 forks source link

add velocities to GRO reader #102

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The GRO file format can also store velocities but we don't read them. Given 
that timesteps recently got the ts._velocities attribute we have the 
infrastructure to deal with the velocities so the GRO reader should be able to 
handle them.

The GRO format is described at http://manual.gromacs.org/online/gro.html

Together with resolving Issue 101 this would add proper velocity processing 
capabilities to MDAnalysis.

Original issue reported on code.google.com by orbeckst on 19 Apr 2012 at 10:49

GoogleCodeExporter commented 9 years ago
I have implemented this functionality in my local git repository. It will read 
the velocities from the .gro file and convert them to A/ps units using the 
built-in velocity conversion function. The velocities can correctly be accessed 
in the following ways:

all_atoms.velocities() #where all_atoms is an AtomGroup with all atoms in the 
system and a matrix of velocities is produced
all_atoms[0].velocity #will produce the velocity of the first atom in the system

Ideally we might want a Unit Test for this, but I'm not clear on what's going 
on there. Just to clarify, if I import the development version of MDA at the 
Python prompt and then import the tests module, which is in another directory 
as it is a separate package now, the tests will always run on the version of 
MDAnalysis that is imported in the current interactive session and not any 
other versions installed on the system, regardless of external python 
path-related settings? 

Original comment by tyler.je.reddy@gmail.com on 27 May 2012 at 12:20

GoogleCodeExporter commented 9 years ago
I'm also not clear on what's going on with the version control on the testing 
package. Even if I have time to make such a test, is there another git 
repository for the testing code?

Original comment by tyler.je.reddy@gmail.com on 27 May 2012 at 12:30

GoogleCodeExporter commented 9 years ago
Hi Tyler,

Thanks for looking at this. I made you the owner of the issue.

1) Both the MDAnalysis package and the test cases (MDAnalysisTests) are in the 
same git repo. One important reason was so that one could check in the test 
cases together with the code changes (see RepositoryStructure and 
DevelopmentWorkflow).

2) I use a developer installation for development and the nosetest picks up the 
current installation (not 100% sure that it picks up the local files if you 
installed MDAnalysis as a non-developer installation). If you run the tests in 
an interactive session then I believe it picks up whatever is installed and if 
you didn't use a developer installation then you'd need to re-run 'python 
setup.py install' after every code change.

To illustrate: I do the following

0. Make sure that you can get the development branch (see also 
DistributedDevelopment)

    git fetch --all
    git checkout -b develop origin/develop

  (This only needs to be done once.)

1. switch to the develop branch if you haven't done this in step 0

     git checkout develop

   You can pull in changes from develop with

     git pull

   (as usual)

2. Create a developer installation:

     cd package
     python setup.py develop

   Depending on where you want to install the link egg file you might have to provide --install-dir/--script-dir or --prefix; on my laptop I am using a ~/.pydistutils.cfg file that holds the defaults
    [install]
    install_lib = ~/.local/lib/python$py_version_short/site-packages
    install_scripts = ~/bin 
   which are more or less equivalent to what 'python setup.py install --user' does but that's just how I do this.

3. Run the test cases that you are interested in:

    cd testsuite/MDAnalysisTests/    
    nosetests -v test_coordinates:TestGROReader test_topology  test_coordinates:TestPrimitivePDBWriter.test_write_single_frame_Writer 

   (See UnitTests for more details and of course the docs for nose.)

4. Write your unit test,  write your code, then test that your own unit tests 
pass.

   Commit your changes, using a message that references Issue 102. Add a note to CHANGELOG (and include your name). Add docs where necessary. Do not push the changes yet.

5. Run ALL unit tests:

    nosetests -v

   If anything fails then you introduced a regression and you need to fix your code. 

6. Once all UnitTests pass (minus the "known failures") you can push your 
changes:

    git commit ...
    git push

Some related thoughts:
- for the docs: change the description of the GRO reader to include velocities 
(also in MDAnalysis/coordinates/__init__.py)
- velocities should be loaded into the Timestep._velocities attribute (see 
http://mdanalysis.googlecode.com/git-history/develop/package/doc/html/documentat
ion_pages/coordinates/init.html#private-attributes); then everything else 
should work automagically (see the TRRReader for how this was done)

Thanks,
Oliver

Original comment by orbeckst on 28 May 2012 at 12:43

GoogleCodeExporter commented 9 years ago
This enhancement has been implemented along with a unit test to ensure that 
AtomGroup.velocities() and Atom.velocity correctly return the respective 
velocity values from a test .gro file. Supports arbitrary precision for 
space-separated columns (as was the case for coordinate reading coded by Danny) 
and uses the ts._velocities attribute.

Original comment by tyler.je.reddy@gmail.com on 3 Jun 2012 at 4:28

GoogleCodeExporter commented 9 years ago

Original comment by orbeckst on 4 Jun 2012 at 6:13