Skip to content
Snippets Groups Projects
Commit 9643b46e authored by Toni G's avatar Toni G
Browse files

updated molfile plugins to latest version

parent c819eb9d
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
See http://www.plumed-code.org for more information. See http://www.plumed-code.org for more information.
This file is part of plumed, version 2.0. This file is part of plumed, version 2.
plumed is free software: you can redistribute it and/or modify plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
See http://www.plumed-code.org for more information. See http://www.plumed-code.org for more information.
This file is part of plumed, version 2.0. This file is part of plumed, version 2.
plumed is free software: you can redistribute it and/or modify plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
......
...@@ -17,7 +17,7 @@ OBJ=dcdplugin.o gromacsplugin.o pdbplugin.o ...@@ -17,7 +17,7 @@ OBJ=dcdplugin.o gromacsplugin.o pdbplugin.o
obj: $(OBJ) obj: $(OBJ)
# Local rules for molfile plugins - replacement is delayed # Local rules for molfile plugins - replacement is delayed
CPPFLAGS+=-DSTATIC_PLUGIN -DVMDPLUGIN=molfile_$(patsubst %.o,%,$@) CPPFLAGS+=-DSTATIC_PLUGIN -DVMDPLUGIN=molfile_$(patsubst %.o,%,$@) -fPIC
# -fpermissive works around a missing cast in pdbplugin # -fpermissive works around a missing cast in pdbplugin
# char *newstr=realloc(pdb->meta->remarks, newlen + 1); # char *newstr=realloc(pdb->meta->remarks, newlen + 1);
......
...@@ -611,7 +611,7 @@ static int read_dcdstep(fio_fd fd, int N, float *X, float *Y, float *Z, ...@@ -611,7 +611,7 @@ static int read_dcdstep(fio_fd fd, int N, float *X, float *Y, float *Z,
iov[6].iov_len = rec_scale*sizeof(int); iov[6].iov_len = rec_scale*sizeof(int);
#if 1 #if 1
/* Use fall-back code instead of readv(): */ /* Use fall-back code instead of readv():
/* Some platforms implement readv() as user level code in libc, */ /* Some platforms implement readv() as user level code in libc, */
/* and due to POSIX atomicity requirements for readv()/writev(), */ /* and due to POSIX atomicity requirements for readv()/writev(), */
/* they may copy data to internal temp buffers, which can kill */ /* they may copy data to internal temp buffers, which can kill */
......
...@@ -48,7 +48,7 @@ OTHER DEALINGS WITH THE SOFTWARE. ...@@ -48,7 +48,7 @@ OTHER DEALINGS WITH THE SOFTWARE.
* *
* $RCSfile: gromacsplugin.C,v $ * $RCSfile: gromacsplugin.C,v $
* $Author: johns $ $Locker: $ $State: Exp $ * $Author: johns $ $Locker: $ $State: Exp $
* $Revision: 1.47 $ $Date: 2012/07/30 21:48:39 $ * $Revision: 1.48 $ $Date: 2014/03/04 21:48:53 $
* *
***************************************************************************/ ***************************************************************************/
...@@ -78,8 +78,31 @@ typedef struct { ...@@ -78,8 +78,31 @@ typedef struct {
md_file *mf; md_file *mf;
int natoms; int natoms;
int step; int step;
float timeval;
molfile_atom_t *atomlist;
molfile_metadata_t *meta;
} gmxdata; } gmxdata;
static void convert_vmd_box_for_writing(const molfile_timestep_t *ts, float *x, float *y, float *z)
{
// const float sa = sin((double)ts->alpha/180.0*M_PI);
const float ca = cos((double)ts->alpha/180.0*M_PI);
const float cb = cos((double)ts->beta/180.0*M_PI);
const float cg = cos((double)ts->gamma/180.0*M_PI);
const float sg = sin((double)ts->gamma/180.0*M_PI);
x[0] = ts->A / ANGS_PER_NM;
y[0] = 0.0;
z[0] = 0.0;
x[1] = ts->B*cg / ANGS_PER_NM; // ts->B*ca when writing trr?!
y[1] = ts->B*sg / ANGS_PER_NM; // ts->B*sa when writing trr?!
z[1] = 0.0;
x[2] = ts->C*cb / ANGS_PER_NM;
y[2] = (ts->C / ANGS_PER_NM)*(ca - cb*cg)/sg;
z[2] = (ts->C / ANGS_PER_NM)*sqrt((double)(1.0 + 2.0*ca*cb*cg
- ca*ca - cb*cb - cg*cg)/(1.0 - cg*cg));
}
static void *open_gro_read(const char *filename, const char *, static void *open_gro_read(const char *filename, const char *,
int *natoms) { int *natoms) {
...@@ -106,6 +129,9 @@ static void *open_gro_read(const char *filename, const char *, ...@@ -106,6 +129,9 @@ static void *open_gro_read(const char *filename, const char *,
gmx = new gmxdata; gmx = new gmxdata;
gmx->mf = mf; gmx->mf = mf;
gmx->natoms = mdh.natoms; gmx->natoms = mdh.natoms;
gmx->meta = new molfile_metadata_t;
strncpy(gmx->meta->title, mdh.title, 80);
gmx->timeval = mdh.timeval;
return gmx; return gmx;
} }
...@@ -115,14 +141,14 @@ static int read_gro_structure(void *mydata, int *optflags, ...@@ -115,14 +141,14 @@ static int read_gro_structure(void *mydata, int *optflags,
md_atom ma; md_atom ma;
char buf[MAX_GRO_LINE + 1]; char buf[MAX_GRO_LINE + 1];
gmxdata *gmx = (gmxdata *)mydata; gmxdata *gmx = (gmxdata *)mydata;
*optflags = MOLFILE_NOOPTIONS; // no optional data *optflags = MOLFILE_NOOPTIONS; // no optional data
// read in each atom and add it into the molecule // read in each atom and add it into the molecule
for (int i = 0; i < gmx->natoms; i++) { for (int i = 0; i < gmx->natoms; i++) {
molfile_atom_t *atom = atoms+i; molfile_atom_t *atom = atoms+i;
if (gro_rec(gmx->mf, &ma) < 0) { if (gro_rec(gmx->mf, &ma) < 0) {
fprintf(stderr, "gromacsplugin) Error reading atom %d from file, %s\n", fprintf(stderr, "gromacsplugin) Error reading atom %d from file, %s\n",
i+1, mdio_errmsg(mdio_errno())); i+1, mdio_errmsg(mdio_errno()));
return MOLFILE_ERROR; return MOLFILE_ERROR;
} }
...@@ -133,23 +159,29 @@ static int read_gro_structure(void *mydata, int *optflags, ...@@ -133,23 +159,29 @@ static int read_gro_structure(void *mydata, int *optflags,
atom->chain[0] = '\0'; atom->chain[0] = '\0';
atom->segid[0] = '\0'; atom->segid[0] = '\0';
} }
if (mdio_readline(gmx->mf, buf, MAX_GRO_LINE + 1, 0) < 0) { if (mdio_readline(gmx->mf, buf, MAX_GRO_LINE + 1, 0) < 0) {
fprintf(stderr, "gromacsplugin) Warning, error reading box, %s\n", fprintf(stderr, "gromacsplugin) Warning, error reading box, %s\n",
mdio_errmsg(mdio_errno())); mdio_errmsg(mdio_errno()));
} }
rewind(gmx->mf->f); rewind(gmx->mf->f);
return MOLFILE_SUCCESS; return MOLFILE_SUCCESS;
} }
static int read_gro_molecule_metadata(void *v, molfile_metadata_t **metadata) {
gmxdata *gmx = (gmxdata *)v;
*metadata = gmx->meta;
return MOLFILE_SUCCESS;
}
static int read_gro_timestep(void *v, int natoms, molfile_timestep_t *ts) { static int read_gro_timestep(void *v, int natoms, molfile_timestep_t *ts) {
gmxdata *gmx = (gmxdata *)v; gmxdata *gmx = (gmxdata *)v;
md_ts mdts; md_ts mdts;
memset(&mdts, 0, sizeof(md_ts)); memset(&mdts, 0, sizeof(md_ts));
mdts.natoms = natoms; mdts.natoms = natoms;
if (mdio_timestep(gmx->mf, &mdts) < 0) if (mdio_timestep(gmx->mf, &mdts) < 0)
return MOLFILE_ERROR; return MOLFILE_ERROR;
if (ts) { if (ts) {
memcpy(ts->coords, mdts.pos, 3 * sizeof(float) * gmx->natoms); memcpy(ts->coords, mdts.pos, 3 * sizeof(float) * gmx->natoms);
...@@ -172,6 +204,93 @@ static void close_gro_read(void *v) { ...@@ -172,6 +204,93 @@ static void close_gro_read(void *v) {
delete gmx; delete gmx;
} }
// open file for writing
static void *open_gro_write(const char *filename, const char *filetype,
int natoms) {
md_file *mf;
gmxdata *gmx;
mf = mdio_open(filename, MDFMT_GRO, MDIO_WRITE);
if (!mf) {
fprintf(stderr, "gromacsplugin) Cannot open file '%s', %s\n",
filename, mdio_errmsg(mdio_errno()));
return NULL;
}
gmx = new gmxdata;
gmx->mf = mf;
gmx->natoms = natoms;
gmx->step = 0;
gmx->meta = new molfile_metadata_t;
gmx->meta->title[0] = '\0';
return gmx;
}
static int write_gro_structure(void *v, int optflags,
const molfile_atom_t *atoms) {
gmxdata *gmx = (gmxdata *)v;
int natoms = gmx->natoms;
gmx->atomlist = (molfile_atom_t *)malloc(natoms*sizeof(molfile_atom_t));
memcpy(gmx->atomlist, atoms, natoms*sizeof(molfile_atom_t));
return MOLFILE_SUCCESS;
}
static int write_gro_timestep(void *v, const molfile_timestep_t *ts) {
gmxdata *gmx = (gmxdata *)v;
const molfile_atom_t *atom;
const float *pos, *vel;
float x[3], y[3], z[3];
int i;
if (gmx->natoms == 0)
return MOLFILE_SUCCESS;
atom = gmx->atomlist;
pos = ts->coords;
vel = ts->velocities;
/* The title cannot be written */
/* fprintf(gmx->mf->f, "%s", gmx->meta->title);*/
/* Write a dummy title instead */
fprintf(gmx->mf->f, "generated by VMD");
#if vmdplugin_ABIVERSION > 10
fprintf(gmx->mf->f, ", t= %f", ts->physical_time);
#endif
fprintf(gmx->mf->f, "\n");
fprintf(gmx->mf->f, "%d\n", gmx->natoms);
for (i=0; i<gmx->natoms; i++)
{
fprintf(gmx->mf->f, "%5d%-5s%5s%5d%8.3f%8.3f%8.3f",
atom->resid, atom->resname, atom->name, i+1,
pos[0] / ANGS_PER_NM, pos[1] / ANGS_PER_NM, pos[2] / ANGS_PER_NM);
if(vel)
{
fprintf(gmx->mf->f, "%8.4f%8.4f%8.4f", vel[0] / ANGS_PER_NM, vel[1] / ANGS_PER_NM, vel[2] / ANGS_PER_NM);
vel += 3;
}
fprintf(gmx->mf->f, "\n");
++atom;
pos += 3;
}
convert_vmd_box_for_writing(ts, x, y, z);
fprintf(gmx->mf->f, "%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f\n", x[0], y[1], z[2], y[0], z[0], x[1], z[1], x[2], y[2]);
return MOLFILE_SUCCESS;
}
static void close_gro_write(void *v) {
gmxdata *gmx = (gmxdata *)v;
mdio_close(gmx->mf);
free(gmx->atomlist);
free(gmx->meta);
free(gmx);
}
static void *open_g96_read(const char *filename, const char *, static void *open_g96_read(const char *filename, const char *,
int *natoms) { int *natoms) {
...@@ -185,7 +304,7 @@ static void *open_g96_read(const char *filename, const char *, ...@@ -185,7 +304,7 @@ static void *open_g96_read(const char *filename, const char *,
filename, mdio_errmsg(mdio_errno())); filename, mdio_errmsg(mdio_errno()));
return NULL; return NULL;
} }
// read in the header data // read in the header data
if (g96_header(mf, mdh.title, MAX_MDIO_TITLE, &mdh.timeval) < 0) { if (g96_header(mf, mdh.title, MAX_MDIO_TITLE, &mdh.timeval) < 0) {
fprintf(stderr, "gromacsplugin) Cannot read header from '%s', %s\n", fprintf(stderr, "gromacsplugin) Cannot read header from '%s', %s\n",
...@@ -213,8 +332,8 @@ static void *open_g96_read(const char *filename, const char *, ...@@ -213,8 +332,8 @@ static void *open_g96_read(const char *filename, const char *,
fprintf(stderr, "gromacsplugin) No structure information in file %s\n", filename); fprintf(stderr, "gromacsplugin) No structure information in file %s\n", filename);
return NULL; return NULL;
} }
*natoms = g96_countatoms(mf); *natoms = g96_countatoms(mf);
gmxdata *gmx = new gmxdata; gmxdata *gmx = new gmxdata;
gmx->mf = mf; gmx->mf = mf;
gmx->natoms = *natoms; gmx->natoms = *natoms;
...@@ -223,16 +342,16 @@ static void *open_g96_read(const char *filename, const char *, ...@@ -223,16 +342,16 @@ static void *open_g96_read(const char *filename, const char *,
static int read_g96_structure(void *mydata, int *optflags, static int read_g96_structure(void *mydata, int *optflags,
molfile_atom_t *atoms) { molfile_atom_t *atoms) {
char gbuf[MAX_G96_LINE + 1]; char gbuf[MAX_G96_LINE + 1];
gmxdata *gmx = (gmxdata *)mydata; gmxdata *gmx = (gmxdata *)mydata;
md_atom ma; md_atom ma;
md_file *mf = gmx->mf; md_file *mf = gmx->mf;
*optflags = MOLFILE_NOOPTIONS; // no optional data *optflags = MOLFILE_NOOPTIONS; // no optional data
for (int i = 0; i < gmx->natoms; i++) { for (int i = 0; i < gmx->natoms; i++) {
molfile_atom_t *atom = atoms+i; molfile_atom_t *atom = atoms+i;
if (g96_rec(mf, &ma) < 0) { if (g96_rec(mf, &ma) < 0) {
fprintf(stderr, "gromacsplugin) Error reading atom %d from file, %s\n", fprintf(stderr, "gromacsplugin) Error reading atom %d from file, %s\n",
i+1, mdio_errmsg(mdio_errno())); i+1, mdio_errmsg(mdio_errno()));
...@@ -245,7 +364,7 @@ static int read_g96_structure(void *mydata, int *optflags, ...@@ -245,7 +364,7 @@ static int read_g96_structure(void *mydata, int *optflags,
atom->chain[0] = '\0'; atom->chain[0] = '\0';
atom->segid[0] = '\0'; atom->segid[0] = '\0';
} }
if (mdio_readline(mf, gbuf, MAX_G96_LINE + 1) < 0) { if (mdio_readline(mf, gbuf, MAX_G96_LINE + 1) < 0) {
fprintf(stderr, "gromacsplugin) Warning, error reading END record, %s\n", fprintf(stderr, "gromacsplugin) Warning, error reading END record, %s\n",
mdio_errmsg(mdio_errno())); mdio_errmsg(mdio_errno()));
...@@ -270,16 +389,16 @@ static int read_g96_structure(void *mydata, int *optflags, ...@@ -270,16 +389,16 @@ static int read_g96_structure(void *mydata, int *optflags,
return MOLFILE_ERROR; return MOLFILE_ERROR;
if (!strcasecmp(gbuf, "END")) break; if (!strcasecmp(gbuf, "END")) break;
} }
// Again, record our position because we may need // Again, record our position because we may need
// to fseek here later if we read too far. // to fseek here later if we read too far.
fpos = ftell(mf->f); fpos = ftell(mf->f);
// Go ahead and read the next line. // Go ahead and read the next line.
if (mdio_readline(mf, gbuf, MAX_G96_LINE + 1) < 0) if (mdio_readline(mf, gbuf, MAX_G96_LINE + 1) < 0)
return MOLFILE_ERROR; return MOLFILE_ERROR;
} }
// Is there a box present ? // Is there a box present ?
if (!strcasecmp(gbuf, "BOX")) { if (!strcasecmp(gbuf, "BOX")) {
// Ignore the box coordinates at this time. // Ignore the box coordinates at this time.
...@@ -287,7 +406,7 @@ static int read_g96_structure(void *mydata, int *optflags, ...@@ -287,7 +406,7 @@ static int read_g96_structure(void *mydata, int *optflags,
return MOLFILE_ERROR; return MOLFILE_ERROR;
if (mdio_readline(mf, gbuf, MAX_G96_LINE + 1) < 0) if (mdio_readline(mf, gbuf, MAX_G96_LINE + 1) < 0)
return MOLFILE_ERROR; return MOLFILE_ERROR;
if (strcasecmp(gbuf, "END")) if (strcasecmp(gbuf, "END"))
return MOLFILE_ERROR; return MOLFILE_ERROR;
} }
else { else {
...@@ -313,7 +432,7 @@ static int read_g96_timestep(void *v, int natoms, molfile_timestep_t *ts) { ...@@ -313,7 +432,7 @@ static int read_g96_timestep(void *v, int natoms, molfile_timestep_t *ts) {
memset(&mdts, 0, sizeof(md_ts)); memset(&mdts, 0, sizeof(md_ts));
mdts.natoms = natoms; mdts.natoms = natoms;
if (mdio_timestep(gmx->mf, &mdts) < 0) if (mdio_timestep(gmx->mf, &mdts) < 0)
return MOLFILE_ERROR; return MOLFILE_ERROR;
if (ts) { if (ts) {
memcpy(ts->coords, mdts.pos, 3 * sizeof(float) * gmx->natoms); memcpy(ts->coords, mdts.pos, 3 * sizeof(float) * gmx->natoms);
...@@ -335,7 +454,7 @@ static void close_g96_read(void *v) { ...@@ -335,7 +454,7 @@ static void close_g96_read(void *v) {
mdio_close(gmx->mf); mdio_close(gmx->mf);
delete gmx; delete gmx;
} }
// //
// TRR and XTC files // TRR and XTC files
...@@ -348,12 +467,12 @@ static void *open_trr_read(const char *filename, const char *filetype, ...@@ -348,12 +467,12 @@ static void *open_trr_read(const char *filename, const char *filetype,
md_header mdh; md_header mdh;
gmxdata *gmx; gmxdata *gmx;
int format; int format;
if (!strcmp(filetype, "trr")) if (!strcmp(filetype, "trr"))
format = MDFMT_TRR; format = MDFMT_TRR;
else if (!strcmp(filetype, "trj")) else if (!strcmp(filetype, "trj"))
format = MDFMT_TRJ; format = MDFMT_TRJ;
else if (!strcmp(filetype, "xtc")) else if (!strcmp(filetype, "xtc"))
format = MDFMT_XTC; format = MDFMT_XTC;
else else
return NULL; return NULL;
...@@ -385,10 +504,10 @@ static int read_trr_timestep(void *v, int natoms, molfile_timestep_t *ts) { ...@@ -385,10 +504,10 @@ static int read_trr_timestep(void *v, int natoms, molfile_timestep_t *ts) {
if (mdio_timestep(gmx->mf, &mdts) < 0) { if (mdio_timestep(gmx->mf, &mdts) < 0) {
if (mdio_errno() == MDIO_EOF || mdio_errno() == MDIO_IOERROR) { if (mdio_errno() == MDIO_EOF || mdio_errno() == MDIO_IOERROR) {
// XXX Lame, why does mdio treat IOERROR like EOF? // XXX Lame, why does mdio treat IOERROR like EOF?
return MOLFILE_ERROR; return MOLFILE_ERROR;
} }
fprintf(stderr, "gromacsplugin) Error reading timestep, %s\n", fprintf(stderr, "gromacsplugin) Error reading timestep, %s\n",
mdio_errmsg(mdio_errno())); mdio_errmsg(mdio_errno()));
return MOLFILE_ERROR; return MOLFILE_ERROR;
} }
...@@ -398,7 +517,7 @@ static int read_trr_timestep(void *v, int natoms, molfile_timestep_t *ts) { ...@@ -398,7 +517,7 @@ static int read_trr_timestep(void *v, int natoms, molfile_timestep_t *ts) {
mdio_tsfree(&mdts); mdio_tsfree(&mdts);
return MOLFILE_ERROR; return MOLFILE_ERROR;
} }
if (ts) { if (ts) {
memcpy(ts->coords, mdts.pos, 3 * sizeof(float) * gmx->natoms); memcpy(ts->coords, mdts.pos, 3 * sizeof(float) * gmx->natoms);
if (mdts.box) { if (mdts.box) {
...@@ -427,10 +546,10 @@ static void *open_trr_write(const char *filename, const char *filetype, ...@@ -427,10 +546,10 @@ static void *open_trr_write(const char *filename, const char *filetype,
md_file *mf; md_file *mf;
gmxdata *gmx; gmxdata *gmx;
int format; int format;
if (!strcmp(filetype, "trr")) if (!strcmp(filetype, "trr"))
format = MDFMT_TRR; format = MDFMT_TRR;
else if (!strcmp(filetype, "xtc")) else if (!strcmp(filetype, "xtc"))
format = MDFMT_XTC; format = MDFMT_XTC;
else else
return NULL; return NULL;
...@@ -453,12 +572,12 @@ static void *open_trr_write(const char *filename, const char *filetype, ...@@ -453,12 +572,12 @@ static void *open_trr_write(const char *filename, const char *filetype,
} }
// write a trr timestep. the file format has a header with each record // write a trr timestep. the file format has a header with each record
static int write_trr_timestep(void *mydata, const molfile_timestep_t *ts) static int write_trr_timestep(void *mydata, const molfile_timestep_t *ts)
{ {
const float nm=0.1; const float nm=0.1;
gmxdata *gmx = (gmxdata *)mydata; gmxdata *gmx = (gmxdata *)mydata;
// determine and write header from structure info. // determine and write header from structure info.
// write trr header. XXX: move this to Gromacs.h ?? // write trr header. XXX: move this to Gromacs.h ??
if (gmx->mf->fmt == MDFMT_TRR) { if (gmx->mf->fmt == MDFMT_TRR) {
...@@ -473,7 +592,7 @@ static int write_trr_timestep(void *mydata, const molfile_timestep_t *ts) ...@@ -473,7 +592,7 @@ static int write_trr_timestep(void *mydata, const molfile_timestep_t *ts)
|| put_trx_int(gmx->mf, 0) // pres_size (ignored) || put_trx_int(gmx->mf, 0) // pres_size (ignored)
|| put_trx_int(gmx->mf, 0) // top_size (ignored) || put_trx_int(gmx->mf, 0) // top_size (ignored)
|| put_trx_int(gmx->mf, 0) // sym_size (ignored) || put_trx_int(gmx->mf, 0) // sym_size (ignored)
|| put_trx_int(gmx->mf, 3*sizeof(float)*gmx->natoms) // coordinates || put_trx_int(gmx->mf, 3*sizeof(float)*gmx->natoms) // coordinates
|| put_trx_int(gmx->mf, 0) // no velocities || put_trx_int(gmx->mf, 0) // no velocities
|| put_trx_int(gmx->mf, 0) // no forces || put_trx_int(gmx->mf, 0) // no forces
|| put_trx_int(gmx->mf, gmx->natoms) // number of atoms || put_trx_int(gmx->mf, gmx->natoms) // number of atoms
...@@ -485,7 +604,7 @@ static int write_trr_timestep(void *mydata, const molfile_timestep_t *ts) ...@@ -485,7 +604,7 @@ static int write_trr_timestep(void *mydata, const molfile_timestep_t *ts)
// set up box according to the VMD unitcell conventions. // set up box according to the VMD unitcell conventions.
// the a-vector is collinear with the x-axis and // the a-vector is collinear with the x-axis and
// the b-vector is in the xy-plane. // the b-vector is in the xy-plane.
const float sa = sin((double)ts->alpha/180.0*M_PI); const float sa = sin((double)ts->alpha/180.0*M_PI);
const float ca = cos((double)ts->alpha/180.0*M_PI); const float ca = cos((double)ts->alpha/180.0*M_PI);
const float cb = cos((double)ts->beta/180.0*M_PI); const float cb = cos((double)ts->beta/180.0*M_PI);
...@@ -495,7 +614,7 @@ static int write_trr_timestep(void *mydata, const molfile_timestep_t *ts) ...@@ -495,7 +614,7 @@ static int write_trr_timestep(void *mydata, const molfile_timestep_t *ts)
box[0] = ts->A; box[1] = 0.0; box[2] = 0.0; box[0] = ts->A; box[1] = 0.0; box[2] = 0.0;
box[3] = ts->B*ca; box[4] = ts->B*sa; box[5] = 0.0; box[3] = ts->B*ca; box[4] = ts->B*sa; box[5] = 0.0;
box[6] = ts->C*cb; box[7] = ts->C*(ca - cb*cg)/sg; box[6] = ts->C*cb; box[7] = ts->C*(ca - cb*cg)/sg;
box[8] = ts->C*sqrt((double)(1.0 + 2.0*ca*cb*cg box[8] = ts->C*sqrt((double)(1.0 + 2.0*ca*cb*cg
- ca*ca - cb*cb - cg*cg)/(1.0 - cg*cg)); - ca*ca - cb*cb - cg*cg)/(1.0 - cg*cg));
for (i=0; i<9; ++i) { for (i=0; i<9; ++i) {
...@@ -528,34 +647,35 @@ static void close_trr_write(void *v) { ...@@ -528,34 +647,35 @@ static void close_trr_write(void *v) {
delete gmx; delete gmx;
} }
#define GROMACS_PLUGIN_MAJOR_VERSION 1 #define GROMACS_PLUGIN_MAJOR_VERSION 0
#define GROMACS_PLUGIN_MINOR_VERSION 0 #define GROMACS_PLUGIN_MINOR_VERSION 9
// //
// plugin registration stuff below // plugin registration stuff below
// //
static molfile_plugin_t gro_plugin = { static molfile_plugin_t gro_plugin = {
vmdplugin_ABIVERSION, // ABI version vmdplugin_ABIVERSION, // ABI version
MOLFILE_PLUGIN_TYPE, // type of plugin MOLFILE_PLUGIN_TYPE, // type of plugin
"gro", // short name of plugin "gro", // short name of plugin
"Gromacs GRO", // pretty name of plugin "Gromacs GRO", // pretty name of plugin
"David Norris, Justin Gullingsrud", // authors "David Norris, Justin Gullingsrud, Magnus Lundborg", // authors
GROMACS_PLUGIN_MAJOR_VERSION, // major version GROMACS_PLUGIN_MAJOR_VERSION, // major version
GROMACS_PLUGIN_MINOR_VERSION, // minor version GROMACS_PLUGIN_MINOR_VERSION, // minor version
VMDPLUGIN_THREADUNSAFE, // is not reentrant VMDPLUGIN_THREADUNSAFE, // is not reentrant
"gro", // filename extension "gro", // filename extension
open_gro_read, open_gro_read,
read_gro_structure, read_gro_structure,
0, 0,
read_gro_timestep, read_gro_timestep,
close_gro_read, close_gro_read,
0, // open_write open_gro_write, // open_write
0, // write_structure write_gro_structure, // write_structure
0, // write_timestep write_gro_timestep, // write_timestep
0, // close_write close_gro_write, // close_write
0, // read_volumetric_metadata 0, // read_volumetric_metadata
0, // read_volumetric_data 0, // read_volumetric_data
0 // read_rawgraphics 0, // read_rawgraphics
read_gro_molecule_metadata // read_molecule_metadata
}; };
static molfile_plugin_t g96_plugin = { static molfile_plugin_t g96_plugin = {
...@@ -654,8 +774,8 @@ static molfile_plugin_t trj_plugin = { ...@@ -654,8 +774,8 @@ static molfile_plugin_t trj_plugin = {
0 // read_rawgraphics 0 // read_rawgraphics
}; };
VMDPLUGIN_API int VMDPLUGIN_init() { VMDPLUGIN_API int VMDPLUGIN_init() {
return 0; return 0;
} }
VMDPLUGIN_API int VMDPLUGIN_register(void *v, vmdplugin_register_cb cb) { VMDPLUGIN_API int VMDPLUGIN_register(void *v, vmdplugin_register_cb cb) {
...@@ -671,12 +791,12 @@ VMDPLUGIN_API int VMDPLUGIN_fini() { ...@@ -671,12 +791,12 @@ VMDPLUGIN_API int VMDPLUGIN_fini() {
return 0; return 0;
} }
#ifdef TEST_G96_PLUGIN #ifdef TEST_G96_PLUGIN
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int natoms; int natoms;
molfile_timestep_t timestep; molfile_timestep_t timestep;
void *v; void *v;
int i; int i;
...@@ -707,7 +827,7 @@ int main(int argc, char *argv[]) { ...@@ -707,7 +827,7 @@ int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int natoms; int natoms;
molfile_timestep_t timestep; molfile_timestep_t timestep;
void *v, *w; void *v, *w;
int i; int i;
...@@ -724,7 +844,7 @@ int main(int argc, char *argv[]) { ...@@ -724,7 +844,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "open_trr_write failed for file %s\n", argv[2]); fprintf(stderr, "open_trr_write failed for file %s\n", argv[2]);
return 1; return 1;
} }
i = 0; i = 0;
while(!read_trr_timestep(v, natoms, &timestep)) { while(!read_trr_timestep(v, natoms, &timestep)) {
++i; ++i;
...@@ -733,7 +853,7 @@ int main(int argc, char *argv[]) { ...@@ -733,7 +853,7 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
} }
fprintf(stderr, "ended read_trr_timestep on step %d\n", i); fprintf(stderr, "ended read_trr_timestep on step %d\n", i);
free(timestep.coords); free(timestep.coords);
close_trr_read(v); close_trr_read(v);
......
...@@ -115,7 +115,7 @@ static void *open_pdb_read(const char *filepath, const char *filetype, ...@@ -115,7 +115,7 @@ static void *open_pdb_read(const char *filepath, const char *filetype,
int len=strlen(pdbstr); int len=strlen(pdbstr);
int newlen = len + pdb->meta->remarklen; int newlen = len + pdb->meta->remarklen;
char *newstr=(char*)realloc(pdb->meta->remarks, newlen + 1); char *newstr=realloc(pdb->meta->remarks, newlen + 1);
if (newstr != NULL) { if (newstr != NULL) {
pdb->meta->remarks = newstr; pdb->meta->remarks = newstr;
pdb->meta->remarks[pdb->meta->remarklen] = '\0'; pdb->meta->remarks[pdb->meta->remarklen] = '\0';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment