Re: [AMBER] Using NetCDF trajectory files as ParmEd structure

From: Jason Swails <jason.swails.gmail.com>
Date: Wed, 27 Nov 2019 13:58:18 -0500

Hi Brian,

I rarely check this list anymore, which is why it's taken me a week to
respond.

This is one of those situations where I was inconsistent in what I wanted
ParmEd to do when, so it can do some unexpected things (like here).

The easiest thing to do in this case would be to assign xyz to the first
set of coordinates:

import parmed as pmd
mol = pmd.load_file(<prmtop>, xyz=pmd.load_file(<mdcrd>).coordinates[0])

I generally found myself wanting to write trajectory structure files like
multi-model PDB files) when I had a trajectory of coordinates available in
a structure instance. There doesn't seem to be a good way of implementing
what I would agree is the "expected" behavior in this instance without
breaking existing workflows.

Thanks,
Jason

On Wed, Nov 20, 2019 at 10:44 AM Brian Radak <brian.radak.gmail.com> wrote:

> I'm having a bit of trouble understanding how the ParmEd Python API handles
> NetCDF trajectory files. For example:
>
> >>> import parmed as pmd
> >>> mol = pmd.load_file(<prmtop>, xyz=<mdcrd>)
>
> Where mdcrd is a NetCDF trajectory from a simulation. The documentation
> states "If the file is a trajectory file, the first frame is used for the
> coordinates." This is more or less what I want - a single structure and, if
> possible, to avoid the time-consuming process of reading a whole
> trajectory. Indeed this is what the object contains (using results from a
> real file now):
>
> >>> mol.coordinates.shape
> (201, 3)
> >>> len(mol.atoms)
> 201
>
> However I see that some of the I/O interfaces instead use the (hidden?)
> method get_coordinates() instead of the coordinate attribute and *this*
> returns the whole trajectory by default:
>
> >>> mol.get_coordinates().shape
> (250, 201, 3)
>
> Thus something like:
> >>> mol.save('foo.pqr')
>
> Actually contains many structures (= not what I expected). This can be
> circumvented by specifying the "coordinates" parameter to save(), but it'd
> be nice if I could just delete all of the frames that I don't want from the
> object -- is this possible? I would like to write several files and it is
> tedious to keep reassigning coordinates plus they are just wasted RAM and
> expensive to copy (e.g. if I want to strip some atoms and write a different
> set of file).
>
> Thanks,
> Brian
> _______________________________________________
> AMBER mailing list
> AMBER.ambermd.org
> http://lists.ambermd.org/mailman/listinfo/amber
>


-- 
Jason M. Swails
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Wed Nov 27 2019 - 11:00:02 PST
Custom Search