dimchris / mdanalysis

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

Failed to write AMBER netcdf trajectory from AtomGroup #116

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

from MDAnalysis.tests.datafiles import *; import MDAnalysis
u = MDAnalysis.Universe(PRMncdf, NCDF)
p = u.selectAtoms("not resname WAT")
W = MDAnalysis.Writer("foo.ncdf", numatoms=p.numberOfAtoms())
for ts in u.trajectory:
    W.write(p.atoms)
W.close()

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

Should write the output trajectory but instead raises exception

<ipython-input-10-054121864949> in <module>()
      1 for ts in u.trajectory:
----> 2     W.write(p.atoms)

.../python/mdanalysis/package/MDAnalysis/coordinates/base.pyc in write(self, 
obj)
    808         else:
    809             try:
--> 810                 ts = obj.ts
    811             except AttributeError:
    812                 try:

.../python/mdanalysis/package/MDAnalysis/core/AtomGroup.pyc in ts(self)
   1345         if self.__ts is None or self.__ts.frame != trj_ts.frame:
   1346             # create a timestep of same type as the underlying trajectory
-> 1347             ts = trj_ts.__class__(self.coordinates())
   1348             ts._unitcell = trj_ts._unitcell.copy()
   1349             ts.frame = trj_ts.frame

.../python/mdanalysis/package/MDAnalysis/coordinates/TRJ.pyc in __init__(self, 
arg, **kwargs)
    208                                 self._velocities = numpy.zeros_like(self._pos)
    209                         else:
--> 210                                 raise ValueError("AMBER timestep has no 
second dimension 3 or 6: shape=%r" % (arg.shape,))
    211                 else:
    212                         raise ValueError("Cannot create an empty Timestep")

ValueError: AMBER timestep has no second dimension 3 or 6: shape=(51, 3)

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

Latest development version on OS X.

Please provide any additional information below.

Problem arose in the context of running rms_fit_trj(), see 
https://groups.google.com/d/topic/mdnalysis-discussion/W7F8TY5n6fw/discussion

Original issue reported on code.google.com by obeck...@asu.edu on 30 Aug 2012 at 12:55

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

Original comment by orbeckst on 3 Sep 2012 at 6:57

GoogleCodeExporter commented 9 years ago
I tested the development version after this fix. Now i am able to write the 
fitted trajectory with ncdf format. However there still lies some problem if i 
try to write the trajectory as multi-frame pdb. The error is pasted below.

Thanks once again,
Bala

Writing pdb gives me the following error.

Traceback (most recent call last):
  File "MDAL_FIT-REF.py", line 17, in <module>
    rms_fit_trj(tar,ref,select=sel,filename='rmsfit.pdb')
  File "/home/cbala/.local/lib/python2.7/site-packages/MDAnalysis-0.7.7_devel-py2.7-linux-x86_64.egg/MDAnalysis/analysis/align.py",
line 380, in rms_fit_trj
    writer = frames.OtherWriter(filename)
  File "/home/cbala/.local/lib/python2.7/site-packages/MDAnalysis-0.7.7_devel-py2.7-linux-x86_64.egg/MDAnalysis/coordinates/base.py",
line 423, in OtherWriter
    return core.writer(filename, **kwargs)
  File "/home/cbala/.local/lib/python2.7/site-packages/MDAnalysis-0.7.7_devel-py2.7-linux-x86_64.egg/MDAnalysis/coordinates/core.py",
line 183, in writer
    return Writer(filename, numatoms=numatoms, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'delta'

Original comment by bala.bio...@gmail.com on 4 Sep 2012 at 7:27

GoogleCodeExporter commented 9 years ago
Hi Bala,

I only just saw your comment at the end of Issue 116 that you're unable to 
write a multi-PDB. You are not showing the exact commands that you're using but 
my suspicion is that you simply forgot to set the multiframe=True flag on the 
writer as in the following (see 
http://packages.python.org/MDAnalysis/documentation_pages/coordinates/PDB.html 
):

from MDAnalysis.tests.datafiles import *; import MDAnalysis
u = MDAnalysis.Universe(PRMncdf, NCDF)
p = u.selectAtoms("not resname WAT")
W = MDAnalysis.Writer("foo.pdb", numatoms=p.numberOfAtoms(), multiframe=True)
for ts in u.trajectory:
    W.write(p.atoms)
W.close()

Unfortunately we need the hack with multiframe=True because there is no other 
way to find out if the user just wants to write a snapshot or a whole 
trajectory.

If this does not do what you want then please file a new issue – comments 
attached to fixed issues are esily ignored.

Oliver

Original comment by orbeckst on 18 Sep 2012 at 6:56