dimchris / mdanalysis

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

Infinite loop when writing single frame #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. u = md.Universe(psf_file, dcd_file)
2. W = md.Writer('last_frame.pdb')
3. u.trajectory[-1]
4. W.write(u.selectAtoms('all'))

What is the expected output? What do you see instead?

Output should be a single pdb named last_frame.pdb

What version of the product are you using? On what operating system?

rev: 82391208d365

Rocks, CentOS, Mac OSX

Please provide any additional information below.

The preceding code produces an infinite loop where the script continues to 
print coordinates more than once into the same file.  The file obviously grows 
as long as script is allowed to run.

Original issue reported on code.google.com by austin.g...@gmail.com on 2 Mar 2012 at 6:36

GoogleCodeExporter commented 9 years ago
Thank you!

(Sorry for the delay in looking at this, since Google deactivated Updates it 
has become harder to keep track of things, see Issue 98. If you feel there 
should have been a response by now – say after 3 days – and nothing has 
happened you can send a quick email to the developer mailing list, 
http://groups.google.com/group/mdnalysis-devel )

Jan, you know the PDBReader/Writer best nowadays. Can you have a look and 
possibly grab the ticket? Or let me know if this is bad timing.

I set the status to accepted because I can easily reproduce the error:

  import MDAnalysis; from MDAnalysis.tests.datafiles import *
  u = MDAnalysis.Universe(PSF, DCD)
  W = MDAnalysis.Writer('last.pdb')
  u.trajectory[-1]
  W.write(u.selectAtoms('all'))

This is not related to looking at the last frame, u.trajectory[50] gives the 
same error.

Even worse, just writing a single AtomGroup from a selection fails:

  u.selectAtoms('all').write("xxx.pdb")

The output file contains an increasing number of copies of the last frame:

 TITLE    FRAME(S) FORM 0, SKIP 1; Created by PrimitvePDBWriter
 CRYST1    0.000    0.000    0.000  90.00  90.00  90.00 P 1           1
 MODEL        1
 ATOM ...
 ENDMDL
 MODEL        2
 ...

This should be fixed and a test case added.

Original comment by orbeckst on 8 Mar 2012 at 11:52

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'll be more proactive next time.  I wasn't sure if you guys were actually 
dev's or if this was a lab project that was developed by graduate students, 
post docs, etc.  I know my lab has several google code projects that are 
active, but we don't really accept issues.

BTW, I'm really glad someone decided to do this.  I am really sick of scripting 
analyses in tcl and now I can make a true analysis pipeline.  

Original comment by austin.g...@gmail.com on 9 Mar 2012 at 12:31

GoogleCodeExporter commented 9 years ago
Glad that it looks useful to you.

As far as the mix of devs goes: post docs, grad students, people working in 
industry, faculty but everyone uses it for their own research and like the code 
to be in usable and working condition. Many users have contributed code (see 
ContributingCode) and the issue reports we get are really very valuable.

(There's also a paper on MDAnalysis and of course it helps us tremendously if 
this is cited by users.)

Original comment by orbeckst on 9 Mar 2012 at 12:45

GoogleCodeExporter commented 9 years ago
The weekend has come and i'll certainly have a look. This is definitely high 
priority. 

Original comment by jan...@gmail.com on 10 Mar 2012 at 6:45

GoogleCodeExporter commented 9 years ago
Ok the confusion comes form indexing. When we access u.trajectory[0] we 
actually get 
>>> print u.trajectory.frame
1

A trajectory of course could start from an arbitrary frame number 'x'. Do we 
then want to access that frame via u.trajectory[0] (give me the first frame, 
whatever its number) or accept the lowest possible u.trajectory['x']?

Original comment by jan...@gmail.com on 10 Mar 2012 at 7:26

GoogleCodeExporter commented 9 years ago
This issue was closed by revision a8a280c5fa90.

Original comment by jan...@gmail.com on 10 Mar 2012 at 7:53

GoogleCodeExporter commented 9 years ago
Many thanks, Jan.

I am currently going through the code to make sure that we can also write 
*single* frames from selections.

Original comment by orbeckst on 11 Mar 2012 at 2:58