4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * Great Red Owns Many ACres of Sand
61 static int read_g96_pos(char line
[],t_symtab
*symtab
,FILE *fp
,char *infile
,
66 int nwanted
,natoms
,atnr
,resnr
,oldres
,newres
,shift
;
67 char anm
[STRLEN
],resnm
[STRLEN
];
83 oldres
= -666; /* Unlikely number for the first residue! */
85 while (!bEnd
&& fgets2(line
,STRLEN
,fp
)) {
86 bEnd
= (strncmp(line
,"END",3) == 0);
87 if (!bEnd
&& (line
[0] != '#')) {
88 if (sscanf(line
+shift
,"%15lf%15lf%15lf",&db1
,&db2
,&db3
) != 3)
89 fatal_error(0,"Did not find 3 coordinates for atom %d in %s\n",
91 if ((nwanted
!= -1) && (natoms
>= nwanted
))
93 "Found more coordinates (%d) in %s than expected %d\n",
94 natoms
,infile
,nwanted
);
96 if (atoms
&& fr
->bAtoms
&&
97 (sscanf(line
,"%5d%c%5s%c%5s%7d",&resnr
,&c1
,resnm
,&c2
,anm
,&atnr
)
107 atoms
->atomname
[natoms
]=put_symtab(symtab
,anm
);
108 if (resnr
!= oldres
) {
110 if (newres
>= atoms
->nr
)
111 fatal_error(0,"More residues than atoms in %s (natoms = %d)",
113 atoms
->resname
[newres
] = put_symtab(symtab
,resnm
);
115 if (newres
> atoms
->nres
)
116 atoms
->nres
= newres
;
119 atoms
->atom
[natoms
].resnr
= resnr
-1;
122 fr
->x
[natoms
][0] = db1
;
123 fr
->x
[natoms
][1] = db2
;
124 fr
->x
[natoms
][2] = db3
;
129 if ((nwanted
!= -1) && natoms
!= nwanted
)
131 "Warning: found less coordinates (%d) in %s than expected %d\n",
132 natoms
,infile
,nwanted
);
140 static int read_g96_vel(char line
[],FILE *fp
,char *infile
,
144 int nwanted
,natoms
=-1,shift
;
147 nwanted
= fr
->natoms
;
149 if (fr
->v
&& fr
->bV
) {
150 if (strcmp(line
,"VELOCITYRED") == 0)
156 while (!bEnd
&& fgets2(line
,STRLEN
,fp
)) {
157 bEnd
= (strncmp(line
,"END",3) == 0);
158 if (!bEnd
&& (line
[0] != '#')) {
159 if (sscanf(line
+shift
,"%15lf%15lf%15lf",&db1
,&db2
,&db3
) != 3)
160 fatal_error(0,"Did not find 3 velocities for atom %d in %s",
162 if ((nwanted
!= -1) && (natoms
>= nwanted
))
163 fatal_error(0,"Found more velocities (%d) in %s than expected %d\n",
164 natoms
,infile
,nwanted
);
166 fr
->v
[natoms
][0] = db1
;
167 fr
->v
[natoms
][1] = db2
;
168 fr
->v
[natoms
][2] = db3
;
173 if ((nwanted
!= -1) && (natoms
!= nwanted
))
175 "Warning: found less velocities (%d) in %s than expected %d\n",
176 natoms
,infile
,nwanted
);
182 int read_g96_conf(FILE *fp
,char *infile
,t_trxframe
*fr
)
184 static t_symtab
*symtab
=NULL
;
185 static char line
[STRLEN
+1]; /* VERY DIRTY, you can not read two *
186 * Gromos96 trajectories at the same time */
187 bool bAtStart
,bTime
,bAtoms
,bPos
,bVel
,bBox
,bEnd
,bFinished
;
189 double db1
,db2
,db3
,db4
,db5
,db6
,db7
,db8
,db9
;
191 bAtStart
= (ftell(fp
) == 0);
193 clear_trxframe(fr
,FALSE
);
203 while ( !fr
->bTitle
&& fgets2(line
,STRLEN
,fp
))
204 fr
->bTitle
= (strcmp(line
,"TITLE") == 0);
206 fgets2(fr
->title
,STRLEN
,fp
);
208 while (!bEnd
&& fgets2(line
,STRLEN
,fp
))
209 bEnd
= (strcmp(line
,"END") == 0);
210 fgets2(line
,STRLEN
,fp
);
213 /* Do not get a line if we are not at the start of the file, *
214 * because without a parameter file we don't know what is in *
215 * the trajectory and we have already read the line in the *
216 * previous call (VERY DIRTY). */
219 bTime
= (strcmp(line
,"TIMESTEP") == 0);
220 bAtoms
= (strcmp(line
,"POSITION") == 0);
221 bPos
= (bAtoms
|| (strcmp(line
,"POSITIONRED") == 0));
222 bVel
= (strncmp(line
,"VELOCITY",8) == 0);
223 bBox
= (strcmp(line
,"BOX") == 0);
225 if (!fr
->bTime
&& !fr
->bX
) {
229 bFinished
= (fgets2(line
,STRLEN
,fp
) == NULL
);
230 while (!bFinished
&& (line
[0] == '#'));
231 sscanf(line
,"%15d%15lf",&(fr
->step
),&db1
);
240 natoms
= read_g96_pos(line
,symtab
,fp
,infile
,fr
);
246 natoms
= read_g96_vel(line
,fp
,infile
,fr
);
252 while (!bEnd
&& fgets2(line
,STRLEN
,fp
)) {
253 bEnd
= (strncmp(line
,"END",3) == 0);
254 if (!bEnd
&& (line
[0] != '#')) {
255 nbp
= sscanf(line
,"%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf",
256 &db1
,&db2
,&db3
,&db4
,&db5
,&db6
,&db7
,&db8
,&db9
);
258 fatal_error(0,"Found a BOX line, but no box in %s",infile
);
259 fr
->box
[XX
][XX
] = db1
;
260 fr
->box
[YY
][YY
] = db2
;
261 fr
->box
[ZZ
][ZZ
] = db3
;
263 fr
->box
[XX
][YY
] = db4
;
264 fr
->box
[XX
][ZZ
] = db5
;
265 fr
->box
[YY
][XX
] = db6
;
266 fr
->box
[YY
][ZZ
] = db7
;
267 fr
->box
[ZZ
][XX
] = db8
;
268 fr
->box
[ZZ
][YY
] = db9
;
274 } while (!bFinished
&& fgets2(line
,STRLEN
,fp
));
276 close_symtab(symtab
);
283 void write_g96_conf(FILE *out
,t_trxframe
*fr
,
284 int nindex
,atom_id
*index
)
297 fprintf(out
,"TITLE\n%s\nEND\n",fr
->title
);
298 if (fr
->bStep
|| fr
->bTime
)
299 /* Officially the time format is %15.9, which is not enough for 10 ns */
300 fprintf(out
,"TIMESTEP\n%15d%15.6f\nEND\n",fr
->step
,fr
->time
);
303 fprintf(out
,"POSITION\n");
304 for(i
=0; i
<nout
; i
++) {
305 if (index
) a
= index
[i
]; else a
= i
;
306 fprintf(out
,"%5d %-5s %-5s%7d%15.9f%15.9f%15.9f\n",
307 (atoms
->atom
[a
].resnr
+1) % 100000,
308 *atoms
->resname
[atoms
->atom
[a
].resnr
],
309 *atoms
->atomname
[a
],(i
+1) % 10000000,
310 fr
->x
[a
][XX
],fr
->x
[a
][YY
],fr
->x
[a
][ZZ
]);
313 fprintf(out
,"POSITIONRED\n");
314 for(i
=0; i
<nout
; i
++) {
315 if (index
) a
= index
[i
]; else a
= i
;
316 fprintf(out
,"%15.9f%15.9f%15.9f\n",
317 fr
->x
[a
][XX
],fr
->x
[a
][YY
],fr
->x
[a
][ZZ
]);
320 fprintf(out
,"END\n");
324 fprintf(out
,"VELOCITY\n");
325 for(i
=0; i
<nout
; i
++) {
326 if (index
) a
= index
[i
]; else a
= i
;
327 fprintf(out
,"%5d %-5s %-5s%7d%15.9f%15.9f%15.9f\n",
328 (atoms
->atom
[a
].resnr
+1) % 100000,
329 *atoms
->resname
[atoms
->atom
[a
].resnr
],
330 *atoms
->atomname
[a
],(i
+1) % 10000000,
331 fr
->v
[a
][XX
],fr
->v
[a
][YY
],fr
->v
[a
][ZZ
]);
334 fprintf(out
,"VELOCITYRED\n");
335 for(i
=0; i
<nout
; i
++) {
336 if (index
) a
= index
[i
]; else a
= i
;
337 fprintf(out
,"%15.9f%15.9f%15.9f\n",
338 fr
->v
[a
][XX
],fr
->v
[a
][YY
],fr
->v
[a
][ZZ
]);
341 fprintf(out
,"END\n");
344 fprintf(out
,"BOX\n");
345 fprintf(out
,"%15.9f%15.9f%15.9f",
346 fr
->box
[XX
][XX
],fr
->box
[YY
][YY
],fr
->box
[ZZ
][ZZ
]);
347 if (fr
->box
[XX
][YY
] || fr
->box
[XX
][ZZ
] || fr
->box
[YY
][XX
] ||
348 fr
->box
[YY
][ZZ
] || fr
->box
[ZZ
][XX
] ||fr
->box
[ZZ
][YY
])
349 fprintf(out
,"%15.9f%15.9f%15.9f%15.9f%15.9f%15.9f",
350 fr
->box
[XX
][YY
],fr
->box
[XX
][ZZ
],fr
->box
[YY
][XX
],
351 fr
->box
[YY
][ZZ
],fr
->box
[ZZ
][XX
],fr
->box
[ZZ
][YY
]);
353 fprintf(out
,"END\n");
357 static void get_coordnum_fp (FILE *in
,char *title
, int *natoms
)
361 fgets2 (title
,STRLEN
,in
);
362 fgets2 (line
,STRLEN
,in
);
363 sscanf (line
,"%d",natoms
);
366 static void get_coordnum (char *infile
,int *natoms
)
371 in
=ffopen(infile
,"r");
372 get_coordnum_fp(in
,title
,natoms
);
376 static bool get_w_conf(FILE *in
, char *infile
, char *title
,
377 t_atoms
*atoms
, int *ndec
, rvec x
[],rvec
*v
, matrix box
)
379 static t_symtab
*symtab
=NULL
;
384 double x1
,y1
,z1
,x2
,y2
,z2
;
386 int natoms
,i
,m
,resnr
,newres
,oldres
,ddist
;
391 oldres
= NOTSET
; /* Unlikely number for the first residue! */
398 fgets2(title
,STRLEN
,in
);
400 /* read the number of atoms */
401 fgets2(line
,STRLEN
,in
);
402 sscanf(line
,"%d",&natoms
);
403 if (natoms
> atoms
->nr
)
404 fatal_error(0,"gro file contains more atoms (%d) than expected (%d)",
406 else if (natoms
< atoms
->nr
)
407 fprintf(stderr
,"Warning: gro file contains less atoms (%d) than expected"
408 " (%d)\n",natoms
,atoms
->nr
);
414 /* just pray the arrays are big enough */
415 for (i
=0; (i
< natoms
) ; i
++) {
416 if ((fgets2 (line
,STRLEN
,in
)) == NULL
) {
417 unexpected_eof(infile
,i
+2);
419 if (strlen(line
) < 39)
420 fatal_error(0,"Invalid line in %s for atom %d:\n%s",infile
,i
+1,line
);
422 /* determine read precision from distance between periods
428 fatal_error(0,"A coordinate in file %s does not contain a '.'",infile
);
429 p2
=strchr(&p1
[1],'.');
438 sprintf(format
,"%%%dlf%%%dlf%%%dlf",ddist
,ddist
,ddist
);
439 /* this will be something like "%8lf%8lf%8lf" */
446 sscanf(name
,"%d",&resnr
);
447 memcpy(name
,line
+5,5);
449 if (resnr
!= oldres
) {
451 if (newres
>= natoms
)
452 fatal_error(0,"More residues than atoms in %s (natoms = %d)",
454 atoms
->resname
[newres
] = put_symtab(symtab
,name
);
458 atoms
->atom
[i
].resnr
= resnr
-1;
461 memcpy(name
,line
+10,5);
462 atoms
->atomname
[i
]=put_symtab(symtab
,name
);
464 /* eventueel controle atomnumber met i+1 */
466 /* coordinates (start after residue shit) */
467 /* 'format' was built previously */
468 if (sscanf (line
+20,format
,&x1
,&y1
,&z1
) != 3) {
477 /* velocities (start after residues and coordinates) */
478 /* 'format' was built previously */
480 if (sscanf (line
+20+(3*ddist
),format
,&x1
,&y1
,&z1
) != 3) {
496 fgets2 (line
,STRLEN
,in
);
497 if (sscanf (line
,"%lf%lf%lf",&x1
,&y1
,&z1
) != 3) {
498 sprintf(buf
,"Bad box in file %s",infile
);
501 /* Generate a cubic box */
502 for(m
=0; (m
<DIM
); m
++)
503 xmin
[m
]=xmax
[m
]=x
[0][m
];
504 for(i
=1; (i
<atoms
->nr
); i
++)
505 for(m
=0; (m
<DIM
); m
++) {
506 xmin
[m
]=min(xmin
[m
],x
[i
][m
]);
507 xmax
[m
]=max(xmax
[m
],x
[i
][m
]);
509 for (i
=0; i
<DIM
; i
++) for (m
=0; m
<DIM
; m
++) box
[i
][m
]=0.0;
510 for(m
=0; (m
<DIM
); m
++)
511 box
[m
][m
]=(xmax
[m
]-xmin
[m
]);
512 fprintf(stderr
,"Generated a cubic box %8.3f x %8.3f x %8.3f\n",
513 box
[XX
][XX
],box
[YY
][YY
],box
[ZZ
][ZZ
]);
516 /* We found the first three values, the diagonal elements */
520 if (sscanf (line
,"%*f%*f%*f%lf%lf%lf%lf%lf%lf",
521 &x1
,&y1
,&z1
,&x2
,&y2
,&z2
) != 6)
522 x1
=y1
=z1
=x2
=y2
=z2
=0.0;
530 close_symtab(symtab
);
535 static void read_whole_conf(char *infile
, char *title
,
536 t_atoms
*atoms
, rvec x
[],rvec
*v
, matrix box
)
542 in
=ffopen(infile
,"r");
544 get_w_conf(in
, infile
, title
, atoms
, &ndec
, x
, v
, box
);
549 static void get_conf(FILE *in
, char *title
, int *natoms
,
550 rvec x
[],rvec
*v
,matrix box
)
556 snew(atoms
.atom
,*natoms
);
558 snew(atoms
.resname
,*natoms
);
559 snew(atoms
.atomname
,*natoms
);
561 get_w_conf(in
,title
,title
,&atoms
,&ndec
,x
,v
,box
);
564 sfree(atoms
.resname
);
565 sfree(atoms
.atomname
);
568 bool gro_next_x_or_v(FILE *status
,t_trxframe
*fr
)
571 char title
[STRLEN
],*p
;
579 snew(atoms
.atom
,fr
->natoms
);
580 atoms
.nres
=fr
->natoms
;
581 snew(atoms
.resname
,fr
->natoms
);
582 snew(atoms
.atomname
,fr
->natoms
);
584 fr
->bV
= get_w_conf(status
,title
,title
,&atoms
,&ndec
,fr
->x
,fr
->v
,fr
->box
);
587 /* prec = 10^ndec: */
588 for(i
=0; i
<ndec
; i
++)
596 sfree(atoms
.resname
);
597 sfree(atoms
.atomname
);
599 if ((p
=strstr(title
,"t=")) != NULL
) {
601 if (sscanf(p
,"%lf",&tt
)==1) {
610 if (atoms
.nr
!= fr
->natoms
)
611 fatal_error(0,"Number of atoms in gro frame (%d) doesn't match the number in the previous frame (%d)",atoms
.nr
,fr
->natoms
);
616 int gro_first_x_or_v(FILE *status
,t_trxframe
*fr
)
621 fprintf(stderr
,"Reading frames from gro file");
622 get_coordnum_fp(status
, title
, &fr
->natoms
);
624 fprintf(stderr
," '%s', %d atoms.\n",title
, fr
->natoms
);
628 fatal_error(1,"No coordinates in gro file\n");
630 snew(fr
->x
,fr
->natoms
);
631 snew(fr
->v
,fr
->natoms
);
632 gro_next_x_or_v(status
, fr
);
637 void write_hconf_indexed_p(FILE *out
,char *title
,t_atoms
*atoms
,
638 int nx
,atom_id index
[], int pr
,
639 rvec
*x
,rvec
*v
,matrix box
)
641 char resnm
[6],nm
[6],format
[100];
642 int ai
,i
,resnr
,l
,vpr
;
644 fprintf (out
,"%s\n",(title
&& title
[0])?title
:bromacs(format
,99));
645 fprintf (out
,"%5d\n",nx
);
646 /* build format string for printing,
647 something like "%8.3f" for x and "%8.4f" for v */
655 sprintf(format
,"%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df\n",
656 l
,pr
,l
,pr
,l
,pr
,l
,vpr
,l
,vpr
,l
,vpr
);
658 sprintf(format
,"%%%d.%df%%%d.%df%%%d.%df\n",l
,pr
,l
,pr
,l
,pr
);
660 for (i
=0; (i
<nx
); i
++) {
663 resnr
=atoms
->atom
[ai
].resnr
;
664 strcpy(resnm
," ??? ");
665 if (resnr
< atoms
->nres
)
666 strcpy(resnm
,*atoms
->resname
[resnr
]);
669 strcpy(nm
,*atoms
->atomname
[ai
]);
673 fprintf(out
,"%5d%-5.5s%5.5s%5d",(resnr
+1)%100000,resnm
,nm
,(ai
+1)%100000);
674 /* next fprintf uses built format string */
677 x
[ai
][XX
], x
[ai
][YY
], x
[ai
][ZZ
], v
[ai
][XX
],v
[ai
][YY
],v
[ai
][ZZ
]);
680 x
[ai
][XX
], x
[ai
][YY
], x
[ai
][ZZ
]);
687 if (box
[XX
][YY
] || box
[XX
][ZZ
] || box
[YY
][XX
] || box
[YY
][ZZ
] ||
688 box
[ZZ
][XX
] || box
[ZZ
][YY
]) {
689 sprintf(format
,"%%%d.%df%%%d.%df%%%d.%df"
690 "%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df\n",
691 l
,pr
,l
,pr
,l
,pr
,l
,pr
,l
,pr
,l
,pr
,l
,pr
,l
,pr
,l
,pr
);
693 box
[XX
][XX
],box
[YY
][YY
],box
[ZZ
][ZZ
],
694 box
[XX
][YY
],box
[XX
][ZZ
],box
[YY
][XX
],
695 box
[YY
][ZZ
],box
[ZZ
][XX
],box
[ZZ
][YY
]);
697 sprintf(format
,"%%%d.%df%%%d.%df%%%d.%df\n",l
,pr
,l
,pr
,l
,pr
);
699 box
[XX
][XX
],box
[YY
][YY
],box
[ZZ
][ZZ
]);
704 void write_hconf_p(FILE *out
,char *title
,t_atoms
*atoms
, int pr
,
705 rvec
*x
,rvec
*v
,matrix box
)
711 for(i
=0; (i
<atoms
->nr
); i
++)
713 write_hconf_indexed_p(out
,title
,atoms
,atoms
->nr
,aa
,pr
,x
,v
,box
);
717 void write_conf_p(char *outfile
, char *title
, t_atoms
*atoms
, int pr
,
718 rvec
*x
, rvec
*v
,matrix box
)
722 out
=ffopen(outfile
,"w");
723 write_hconf_p(out
,title
,atoms
,pr
,x
,v
,box
);
728 static void write_conf(char *outfile
, char *title
, t_atoms
*atoms
,
729 rvec
*x
, rvec
*v
,matrix box
)
731 write_conf_p(outfile
, title
, atoms
, 3, x
, v
, box
);
734 void write_sto_conf_indexed(char *outfile
,char *title
,t_atoms
*atoms
,
735 rvec x
[],rvec
*v
,matrix box
,
736 atom_id nindex
,atom_id index
[])
745 out
=ffopen(outfile
,"w");
746 write_hconf_indexed_p(out
, title
, atoms
, nindex
, index
, 3, x
, v
, box
);
750 clear_trxframe(&fr
,TRUE
);
753 fr
.natoms
= atoms
->nr
;
763 copy_mat(box
,fr
.box
);
764 out
=ffopen(outfile
,"w");
765 write_g96_conf(out
, &fr
, nindex
, index
);
771 out
=ffopen(outfile
,"w");
772 write_pdbfile_indexed(out
, title
, atoms
, x
, box
, 0, -1, nindex
, index
);
778 fatal_error(0,"Sorry, can not write a topology to %s",outfile
);
781 fatal_error(0,"Not supported in write_sto_conf_indexed: %s",outfile
);
785 void write_sto_conf(char *outfile
, char *title
,t_atoms
*atoms
,
786 rvec x
[],rvec
*v
, matrix box
)
795 write_conf(outfile
, title
, atoms
, x
, v
, box
);
798 clear_trxframe(&fr
,TRUE
);
801 fr
.natoms
= atoms
->nr
;
811 copy_mat(box
,fr
.box
);
812 out
=ffopen(outfile
,"w");
813 write_g96_conf(out
, &fr
, -1, NULL
);
819 out
=ffopen(outfile
,"w");
820 write_pdbfile(out
, title
, atoms
, x
, box
, 0, -1);
826 fatal_error(0,"Sorry, can not write a topology to %s",outfile
);
829 fatal_error(0,"Not supported in write_sto_conf: %s",outfile
);
833 void get_stx_coordnum(char *infile
,int *natoms
)
836 int ftp
,tpxver
,tpxgen
;
842 get_coordnum(infile
, natoms
);
845 in
=ffopen(infile
,"r");
852 *natoms
=read_g96_conf(in
,infile
,&fr
);
858 in
=ffopen(infile
,"r");
859 get_pdb_coordnum(in
, natoms
);
867 read_tpxheader(infile
,&tpx
,TRUE
,&tpxver
,&tpxgen
);
868 *natoms
= tpx
.natoms
;
872 fatal_error(0,"Not supported in get_stx_coordnum: %s",infile
);
876 void read_stx_conf(char *infile
, char *title
,t_atoms
*atoms
,
877 rvec x
[],rvec
*v
, matrix box
)
887 fprintf(stderr
,"Warning: Number of atoms in %s is 0\n",infile
);
888 else if (atoms
->atom
== NULL
) {
889 sprintf(buf
,"Uninitialized array atom in %s, %d",__FILE__
,__LINE__
);
895 read_whole_conf(infile
, title
, atoms
, x
, v
, box
);
899 fr
.natoms
= atoms
->nr
;
904 in
= ffopen(infile
,"r");
905 read_g96_conf(in
, infile
, &fr
);
907 copy_mat(fr
.box
,box
);
912 read_pdb_conf(infile
, title
, atoms
, x
, box
, TRUE
);
918 read_tpx(infile
,&i1
,&r1
,&r2
,NULL
,box
,&natoms
,x
,v
,NULL
,top
);
920 strcpy(title
,*(top
->name
));
922 atoms
->nr
= top
->atoms
.nr
;
923 atoms
->nres
= top
->atoms
.nres
;
924 atoms
->ngrpname
= top
->atoms
.ngrpname
;
928 snew(atoms
->atom
,atoms
->nr
);
929 if (!atoms
->atomname
)
930 snew(atoms
->atomname
,atoms
->nr
);
931 if (!atoms
->atomtype
)
932 snew(atoms
->atomtype
,atoms
->nr
);
933 if (!atoms
->atomtypeB
)
934 snew(atoms
->atomtypeB
,atoms
->nr
);
935 for(i
=0; (i
<atoms
->nr
); i
++) {
936 atoms
->atom
[i
] = top
->atoms
.atom
[i
];
937 atoms
->atomname
[i
] = top
->atoms
.atomname
[i
];
938 atoms
->atomtype
[i
] = top
->atoms
.atomtype
[i
];
939 atoms
->atomtypeB
[i
] = top
->atoms
.atomtypeB
[i
];
944 snew(atoms
->resname
,atoms
->nres
);
945 for(i
=0; (i
<atoms
->nres
); i
++)
946 atoms
->resname
[i
] = top
->atoms
.resname
[i
];
949 snew(atoms
->grpname
,atoms
->ngrpname
);
950 for(i
=0; (i
<atoms
->ngrpname
); i
++)
951 atoms
->grpname
[i
] = top
->atoms
.grpname
[i
];
953 for(i
=0; (i
<egcNR
); i
++) {
954 atoms
->grps
[i
].nr
= top
->atoms
.grps
[i
].nr
;
955 if (atoms
->grps
[i
].nr
> 0) {
956 snew(atoms
->grps
[i
].nm_ind
,atoms
->grps
[i
].nr
);
957 memcpy(atoms
->grps
[i
].nm_ind
,top
->atoms
.grps
[i
].nm_ind
,
958 atoms
->grps
[i
].nr
*sizeof(atoms
->grps
[i
].nm_ind
[0]));
962 /* Ignore exclusions */
966 fatal_error(0,"Not supported in read_stx_conf: %s",infile
);