[gmx-users] combining two .gro files
Anton Feenstra
feenstra at chem.vu.nl
Tue Sep 17 16:07:46 CEST 2002
Hi All,
While processing a number of mutant proteins with ligand(s) bound,
I wrote a script that 'adds' two .gro files together: it appends atoms
from both files into a new file. This makes it easier to let pdb2gmx
only process the protein and later add the ligand back in, even in a
script. I called it 'gromerge' and it is attached.
--
Groetjes,
Anton
________ ___________________________________________________________
| | Anton Feenstra |
| . | Dept. of Pharmacochemistry - Vrije Universiteit Amsterdam |
| |---- | De Boelelaan 1083 - 1081 HV Amsterdam - The Netherlands |
| |---- | Tel: +31 20 44 47608 - Fax: +31 20 44 47610 |
| ' __ | Feenstra at chem.vu.nl - http://www.chem.vu.nl/afdelingen/FAR|
| / \ |-----------------------------------------------------------|
| ( ) | Dept. of Biophysical Chemistry - University of Groningen |
| \__/ | Nijenborgh 4 - 9747 AG Groningen - The Netherlands |
| __ | Tel +31 50 363 4327 - Fax +31 50 363 4800 |
| / \ | K.A.Feenstra at chem.rug.nl - http://md.chem.rug.nl/~anton |
| ( ) |-----------------------------------------------------------|
| \__/ | "We All Get the Flu, We All Get Aids" (LIVE) |
|________|___________________________________________________________|
-------------- next part --------------
#!/bin/awk -f
BEGIN {
if ( ! outfile ) outfile = "merged.gro";
nfile=0;
natom=0;
}
FNR==1 {
nfile++;
title[nfile] = $0;
name[nfile] = FILENAME;
}
FNR==2 { natoms[nfile] = $1 }
FNR>2 {
if (natom==natoms[nfile]) {
box[nfile] = $0;
nbox[nfile] = NF;
} else
atoms[natom++]=$0;
}
END {
printf "Writing %d files (", nfile;
for(f=1; f<=nfile; f++)
printf "%s%s", (f>1?" ":""), name[f];
printf ") to %s\n", outfile;
natoms[0]=0;
title[0]="";
for(f=1; f<=nfile; f++) {
natoms[0]+=natoms[f];
title[0] = title[0] (f>1?" + ":"") title[f];
split(box[f], b);
if ( (b[1] || b[2] || b[3]) && (nbox[f] >= nbox[0]) ) {
box[0] = box[f];
boxf = f;
}
}
printf "Found %d atoms in total\n", natom;
n=split(box[0], b);
printf "Using box from %s:", name[boxf];
for(i=1; i<=n; i++)
printf " %g", b[i];
printf "\n";
print title[0] > outfile;
print natoms[0] > outfile;
for(i=0; i<natom; i++)
print atoms[i] > outfile;
print box[0] > outfile;
}
#last line
More information about the gromacs.org_gmx-users
mailing list