I am trying to load a .crd
file from Amber, but this fails because it's not in the format MDAnalysis expect (see error at the end):
topology = 'top.prmtop'
trajectory = 'amberOut.crd'
u = MDAnalysis.Universe(topology, trajectory)
I saw this thread and also this library which I don't want to use if I can read Amber .crd file using MDAnalysis.
Any ideas why it doesn't work? If I load the trajectory in VMD I am using this command (and it works):
vmd -parm7 top.prmtop -crdbox amberOut.crd
Traceback (most recent call last):
File "analysis.py", line 5, in <module>
u = MDAnalysis.Universe(topology, trajectory)
File "/anaconda3/envs/mdaenv/lib/python2.7/site-packages/MDAnalysis/core/universe.py", line 305, in __init__
self.load_new(coordinatefile, **kwargs)
File "/anaconda3/envs/mdaenv/lib/python2.7/site-packages/MDAnalysis/core/universe.py", line 535, in load_new
self.trajectory = reader(filename, **kwargs)
File "/anaconda3/envs/mdaenv/lib/python2.7/site-packages/MDAnalysis/coordinates/base.py", line 1943, in __init__
self._read_first_frame()
File "/anaconda3/envs/mdaenv/lib/python2.7/site-packages/MDAnalysis/coordinates/CRD.py", line 73, in _read_first_frame
natoms = int(fields[0])
ValueError: invalid literal for int() with base 10: '96.380'
Use the format="TRJ"
keyword argument for the Universe in your command:
u = MDAnalysis.Universe("top.prmtop", "amberOut.crd", format="TRJ")
You said you used VMD with "crdbox" and the "crdbox" extension is recognized by MDAnalysis as an Amber ASCII trajectory. However, the "crd" extension that you used for your file is already used for CHARMM coordinate files ("CRD" files) and so you need to explicitly specify the trajectory format for the Universe
.
(If you give your trajectories the extension "crdbox" or "trj" such as "amberOut.crdbox" or "amberOut.trj" then MDAnalysis will automatically recognize it as an Amber ASCII trajectory. However, you can always override the format detection with the explicit format
keyword argument.)
Update: Based on this question, we updated the MDAnalysis docs for the Amber trajectory reader to include a note for how to read Amber "crd" trajectories.