4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-2001
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
34 * Gromacs Runs On Most of All Computer Systems
36 static char *SRCID_mkyaw_c = "$Id$";
60 void copy_atom(t_symtab *tab,t_atoms *a1,int i1,t_atoms *a2,int i2,
61 rvec xin[],rvec xout[],rvec vin[],rvec vout[])
63 a2->atom[i2] = a1->atom[i1];
64 a2->atomname[i2] = put_symtab(tab,*a1->atomname[i1]);
65 a2->resname[a2->atom[i2].resnr] =
66 put_symtab(tab,*a1->resname[a1->atom[i1].resnr]);
67 copy_rvec(xin[i1],xout[i2]);
68 copy_rvec(vin[i1],vout[i2]);
71 int main(int argc, char *argv[])
74 static char *desc[] = {
75 "mkyaw adds to an existing conf file for every OW atom an DW and SW",
76 "after the hydrogens (or the inverse with the -back option)."
78 static bool bBack=FALSE,bDW=TRUE;
80 { "-back", FALSE, etBOOL, &bBack,
82 { "-dw", FALSE, etBOOL, &bDW,
83 "Use both dummy and shell" }
87 { efSTX, "-f", NULL, ffREAD },
88 { efSTO, "-o", NULL, ffWRITE }
90 #define NFILE asize(fnm)
92 rvec *xin,*vin,*xout,*vout;
95 char *infile,*outfile,title[256];
97 CopyRight(stderr,argv[0]);
98 parse_common_args(&argc,argv,0,FALSE,NFILE,fnm,NPA,pa,
99 asize(desc),desc,0,NULL);
101 infile = ftp2fn(efSTX,NFILE,fnm);
102 outfile = ftp2fn(efSTO,NFILE,fnm);
104 get_stx_coordnum(infile,&natom);
105 init_t_atoms(&atoms,natom,TRUE);
108 read_stx_conf(infile,title,&atoms,xin,vin,box);
109 printf("Read %d atoms\n",atoms.nr);
113 for(i=0; (i<natom-2); ) {
114 if ((strstr(*atoms.atomname[i],"OW") != NULL) &&
115 (strstr(*atoms.atomname[i+1],"HW") != NULL) &&
116 (strstr(*atoms.atomname[i+2],"HW") != NULL)) {
123 fprintf(stderr,"There are %d water molecules\n",now);
124 init_t_atoms(&aout,natom+2*now,TRUE);
125 snew(xout,natom+2*now);
126 snew(vout,natom+2*now);
127 for(i=iout=0; (i<natom); i++) {
128 copy_atom(&tab,&atoms,i,&aout,iout,xin,xout,vin,vout);
131 if (strstr(*atoms.atomname[i-2],"OW") != NULL) {
133 copy_atom(&tab,&atoms,i-2,&aout,iout,xin,xout,vin,vout);
134 aout.atomname[iout] = put_symtab(&tab,"DW");
137 copy_atom(&tab,&atoms,i-2,&aout,iout,xin,xout,vin,vout);
138 aout.atomname[iout] = put_symtab(&tab,"SW");
145 fprintf(stderr,"iout = %d\n",iout);
146 write_sto_conf(outfile,"Gravity Sucks",&aout,xout,vout,box);