mxdrfile is a set of wrapper functions that enables reading and writing Gromacs .xtc and .trr trajectory files in Matlab. The wrapper functions make direct use of the xdrfile library from Gromacs through the intrinsic loadlibrary function in Matlab.
The mxdrfile wrapper functions were created with the aim of improving the abilities of fast trajectory analysis in Matlab. The library enables reading and writing of .xtc and .trr trajectory files through the use of the original xdrfile library from the Gromacs team.
Both the latest version of the xdrfile library and mxdrfile are open source and released under a BSD license.
Copyright © 2014 Jon Kapla. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> cd my/path/to/mxdrfile
> make
Pay attention to any errors in the make procedure. If needed install required libraries and/or consult the libxdrfile documentation.
> make test
If all went ok, the library can be loaded in Matlab with:
> loadmxdrfile
or
> addpath(genpath(fullpath(‘my’,’path’,’to’,’mxdrfile’,’mxdrfunctions’)))
> loadlibrary(‘libxdrfile’,@fileheaders)
The library read and write functions can be tested by running the included test scripts test_trr.m and test_xtc.m in Matlab after completing the above install procedure.
–> FILE: @mxdrfile/mxdrfile.m
USAGE: trj=mxdrfile(trajfile [,indexfile])
–> FILE: inittraj.m
USAGE: [status,initstruct]=inittraj(fname,action)
–> FILE: closetraj.m
USAGE: [status,initstruct]=closetraj(initstruct) Warning! Operating on a closed lib.pointer file handle may cause segmentation faults. Make sure to “pass by reference” using initstruct as both input and output when closing trajectories!
–> FILE: read_xtc.m
USAGE: [rstatus,trajstruct]=read_xtc(initstruct)
–> FILE: read_trr.m
USAGE: [rstatus,trajstruct]=read_xtc(initstruct)
–> FILE: write_xtc.m
USAGE: wstatus=write_xtc(initstruct, trajstruct)
–> FILE: write_trr.m
USAGE: wstatus=write_trr(initstruct, trajstruct)
–> FILE: catch_xdr_errors.m
USAGE: catch_xdr_errors(status)
–> FILE: read_xtc_natoms.m
USAGE: [status,natoms]=read_xtc_natoms(fname)
–> FILE: read_trr_natoms.m
USAGE: [status,natoms]=read_trr_natoms(fname)
–> FILE: read_ndx.m
USAGE: ndx=read_ndx(ndxfile)