The insertion codes are discarded when converting to GRO files,
which results in adjacent residues with different names but
identical numbers. The reading code has been altered to identify
new residues also when the resname changes; this does not fix
the duplicate numbers (it cannot be fixed in GRO files), but it
will correctly propagate all data so the correct labels can
be recovered by using gmx trjconv with the original PDB file for
the -s argument.
Fixes #1600.
Change-Id: Iaf79f3f9e548e8555d78cb39e869410aa8186029
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
rvec x[], rvec *v, matrix box)
{
char name[6];
rvec x[], rvec *v, matrix box)
{
char name[6];
+ char resname[6], oldresname[6];
char line[STRLEN+1], *ptr;
char buf[256];
double x1, y1, z1, x2, y2, z2;
char line[STRLEN+1], *ptr;
char buf[256];
double x1, y1, z1, x2, y2, z2;
+ resname[0] = '\0';
+ oldresname[0] = '\0';
+
/* just pray the arrays are big enough */
for (i = 0; (i < natoms); i++)
{
/* just pray the arrays are big enough */
for (i = 0; (i < natoms); i++)
{
memcpy(name, line, 5);
name[5] = '\0';
sscanf(name, "%d", &resnr);
memcpy(name, line, 5);
name[5] = '\0';
sscanf(name, "%d", &resnr);
- memcpy(name, line+5, 5);
- name[5] = '\0';
- if (resnr != oldres)
+ sscanf(line+5, "%5s", resname);
+
+ if (resnr != oldres || strncmp(resname, oldresname, sizeof(resname)))
{
oldres = resnr;
newres++;
{
oldres = resnr;
newres++;
infile, natoms);
}
atoms->atom[i].resind = newres;
infile, natoms);
}
atoms->atom[i].resind = newres;
- t_atoms_set_resinfo(atoms, i, symtab, name, resnr, ' ', 0, ' ');
+ t_atoms_set_resinfo(atoms, i, symtab, resname, resnr, ' ', 0, ' ');
memcpy(name, line+10, 5);
atoms->atomname[i] = put_symtab(symtab, name);
memcpy(name, line+10, 5);
atoms->atomname[i] = put_symtab(symtab, name);
+ /* Copy resname to oldresname after we are done with the sanity check above */
+ strncpy(oldresname, resname, sizeof(oldresname));
+
/* eventueel controle atomnumber met i+1 */
/* coordinates (start after residue data) */
/* eventueel controle atomnumber met i+1 */
/* coordinates (start after residue data) */