4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_mkyaw_c
= "$Id$";
53 void copy_atom(t_symtab
*tab
,t_atoms
*a1
,int i1
,t_atoms
*a2
,int i2
,
54 rvec xin
[],rvec xout
[],rvec vin
[],rvec vout
[])
56 a2
->atom
[i2
] = a1
->atom
[i1
];
57 a2
->atomname
[i2
] = put_symtab(tab
,*a1
->atomname
[i1
]);
58 a2
->resname
[a2
->atom
[i2
].resnr
] =
59 put_symtab(tab
,*a1
->resname
[a1
->atom
[i1
].resnr
]);
60 copy_rvec(xin
[i1
],xout
[i2
]);
61 copy_rvec(vin
[i1
],vout
[i2
]);
64 int main(int argc
, char *argv
[])
67 static char *desc
[] = {
68 "mkyaw adds to an existing conf file for every OW atom an DW and SW",
69 "after the hydrogens (or the inverse with the -back option)."
71 static bool bBack
= FALSE
;
73 { "-back", FALSE
, etBOOL
, &bBack
,
78 { efSTX
, "-f", NULL
, ffREAD
},
79 { efSTO
, "-o", NULL
, ffWRITE
}
81 #define NFILE asize(fnm)
83 rvec
*xin
,*vin
,*xout
,*vout
;
86 char *infile
,*outfile
,title
[256];
88 CopyRight(stderr
,argv
[0]);
89 parse_common_args(&argc
,argv
,0,FALSE
,NFILE
,fnm
,NPA
,pa
,
90 asize(desc
),desc
,0,NULL
);
92 infile
= ftp2fn(efSTX
,NFILE
,fnm
);
93 outfile
= ftp2fn(efSTO
,NFILE
,fnm
);
95 get_stx_coordnum(infile
,&natom
);
96 init_t_atoms(&atoms
,natom
,TRUE
);
99 read_stx_conf(infile
,title
,&atoms
,xin
,vin
,box
);
100 printf("Read %d atoms\n",atoms
.nr
);
104 for(i
=0; (i
<natom
-2); ) {
105 if ((strstr(*atoms
.atomname
[i
],"OW") != NULL
) &&
106 (strstr(*atoms
.atomname
[i
+1],"HW") != NULL
) &&
107 (strstr(*atoms
.atomname
[i
+2],"HW") != NULL
)) {
114 fprintf(stderr
,"There are %d water molecules\n",now
);
115 init_t_atoms(&aout
,natom
+2*now
,TRUE
);
116 snew(xout
,natom
+2*now
);
117 snew(vout
,natom
+2*now
);
118 for(i
=iout
=0; (i
<natom
); i
++) {
119 copy_atom(&tab
,&atoms
,i
,&aout
,iout
,xin
,xout
,vin
,vout
);
122 if (strstr(*atoms
.atomname
[i
-2],"OW") != NULL
) {
123 copy_atom(&tab
,&atoms
,i
-2,&aout
,iout
,xin
,xout
,vin
,vout
);
124 aout
.atomname
[iout
] = put_symtab(&tab
,"DW");
126 copy_atom(&tab
,&atoms
,i
-2,&aout
,iout
,xin
,xout
,vin
,vout
);
127 aout
.atomname
[iout
] = put_symtab(&tab
,"SW");
133 fprintf(stderr
,"iout = %d\n",iout
);
134 write_sto_conf(outfile
,"Gravity Sucks",&aout
,xout
,vout
,box
);