[MMTK] Convert LAMMPS MD trajectory to netCDF format with MMTK convention for nMoldyn analysis.

Konrad Hinsen hinsen at cnrs-orleans.fr
Thu Jan 22 13:25:33 UTC 2009


On 22.01.2009, at 08:10, Yi Liu wrote:

> text format, and then used ncgen to generate a binary "nc" file. But I
> encountered the following error:
>
> ncgen -o G4-np2_nvt_trim_shrink.nc G4-np2_nvt_trim_shrink.cdl
> ncgen: G4-np2_nvt_trim_shrink.cdl line 25: string too long, truncated
>
> I guess it is related to the description line in the cdl file. Can
> anyone have a look at the description line and see if it is correct?

If ncgen complains, there must be a simple problem, such as a syntax  
error or an inconsistency in the number of characters. That is indeed  
the case: the string in the cdl file is broken into six pieces, each  
but the first one having 8096 characters. The sum of the six pieces  
has 43091 characters, which seems OK. This looks like something went  
wrong when you generated the cdl file.

I removed the ", " sequences that separate the six parts, and get a  
string that should work fine (I can paste it into Python and get a  
string object of the correct length). Nevertheless, ncgen still  
prints the same error message. I wonder if perhaps ncgen has a limit  
for string lengths.

> Is there a easy way to get this description line correct?

Unfortunately not. The format was created for flexibility and  
simplicity (in MMTK), and in fact it is simply a Python expression  
that is evaluated in a specific context to recreate the universe. I  
don't expect it to be easy to create valid description strings  
otherwise than by constructing a universe in MMTK and asking for its  
description string.

I am working on the next-generation trajectory system, based on HDF5  
instead of netCDF, in which the system description will be stored in  
a more accessible and moreover documented way. That will make it much  
easier to process MMTK-compatible files without actually using MMTK.  
However, the new system is far from ready; you can expect a beta  
release in a few months.

> I can provide further details on how did I create the cdl file if
> necessary. At this moment I want to simplify the problem to how to
> create the description line based on a given pdb file (may not be
> standard).

You could try the script at the end of this message. It uses the  
(rather new) module PDBMoleculeFactory of MMTK, which does not try to  
interpret the PDB file in any way, i.e. it does not assume that it  
contains known molecules. It should work for any file that is  
syntactically a correct PDB file.

Konrad.
--
---------------------------------------------------------------------
Konrad Hinsen
Centre de Biophysique Moléculaire, CNRS Orléans
Synchrotron Soleil - Division Expériences
Saint Aubin - BP 48
91192 Gif sur Yvette Cedex, France
Tel. +33-1 69 35 97 15
E-Mail: hinsen at cnrs-orleans.fr
---------------------------------------------------------------------


from MMTK import *
from MMTK.PDB import PDBConfiguration
from MMTK.PDBMoleculeFactory import PDBMoleculeFactory

conf = PDBConfiguration('G4-np2-nw_namd.pdb')
factory = PDBMoleculeFactory(conf)

universe = InfiniteUniverse()
universe.addObject(factory.retrieveMolecules())
universe.configuration()

description = universe.description()

print description




More information about the mmtk mailing list