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_g_sas_c
= "$Id$";
50 void connelly_plot(char *fn
,int ndots
,real dots
[],rvec x
[],t_atoms
*atoms
,
51 t_symtab
*symtab
,matrix box
)
53 static char *atomnm
="DOT";
54 static char *resnm
="DOT";
55 static char *title
="Connely Dot Surface Generated by g_sas";
61 srenew(atoms
->atom
,atoms
->nr
+ndots
);
62 srenew(atoms
->atomname
,atoms
->nr
+ndots
);
63 srenew(atoms
->resname
,atoms
->nr
+ndots
);
64 srenew(atoms
->pdbinfo
,atoms
->nr
+ndots
);
65 snew(xnew
,atoms
->nr
+ndots
);
66 for(i
=0; (i
<atoms
->nr
); i
++)
67 copy_rvec(x
[i
],xnew
[i
]);
68 for(i
=k
=0; (i
<ndots
); i
++) {
70 atoms
->resname
[ii0
] = put_symtab(symtab
,resnm
);
71 atoms
->atomname
[ii0
] = put_symtab(symtab
,atomnm
);
72 strcpy(atoms
->pdbinfo
[ii0
].pdbresnr
,"1");
73 atoms
->pdbinfo
[ii0
].type
= epdbATOM
;
74 atoms
->atom
[ii0
].chain
= ' ';
75 atoms
->pdbinfo
[ii0
].atomnr
= ii0
;
76 atoms
->atom
[ii0
].resnr
= 1;
77 xnew
[ii0
][XX
] = dots
[k
++];
78 xnew
[ii0
][YY
] = dots
[k
++];
79 xnew
[ii0
][ZZ
] = dots
[k
++];
80 atoms
->pdbinfo
[ii0
].bfac
= 0.0;
81 atoms
->pdbinfo
[ii0
].occup
= 0.0;
84 write_sto_conf(fn
,title
,atoms
,xnew
,NULL
,box
);
90 real
calc_radius(char *atom
)
116 void sas_plot(int nfile
,t_filenm fnm
[],real solsize
,int ndots
,
122 int i
,j
,natoms
,flag
,nsurfacedots
;
128 real
*radius
,*area
=NULL
,*surfacedots
=NULL
;
129 real totarea
,totvolume
,harea
;
131 if ((natoms
=read_first_x(&status
,ftp2fn(efTRX
,nfile
,fnm
),
133 fatal_error(0,"Could not read coordinates from statusfile\n");
134 top
=read_top(ftp2fn(efTPX
,nfile
,fnm
));
136 /* Now comput atomic readii including solvent probe size */
138 snew(bPhobic
,natoms
);
139 for(i
=0; (i
<natoms
); i
++) {
140 radius
[i
] = calc_radius(*(top
->atoms
.atomname
[i
])) + solsize
;
141 bPhobic
[i
] = fabs(top
->atoms
.atom
[i
].q
) <= qcut
;
143 fp
=xvgropen(ftp2fn(efXVG
,nfile
,fnm
),"Solvent Accessible Surface","Time (ps)",
149 fprintf(stderr
,"\rframe: %5d",j
-1);
151 if ((nskip
> 0) && (((j
-1) % nskip
) == 0)) {
152 rm_pbc(&top
->idef
,natoms
,box
,x
,x
);
154 bConnelly
= ((j
== 1) && (opt2bSet("-q",nfile
,fnm
)));
156 flag
= FLAG_ATOM_AREA
| FLAG_DOTS
;
158 flag
= FLAG_ATOM_AREA
;
160 if (NSC(x
[0],radius
,natoms
,ndots
,flag
,&totarea
,
161 &area
,&totvolume
,&surfacedots
,&nsurfacedots
))
162 fatal_error(0,"Something wrong in NSC");
165 connelly_plot(ftp2fn(efPDB
,nfile
,fnm
),
166 nsurfacedots
,surfacedots
,x
,&(top
->atoms
),
170 for(i
=0; (i
<natoms
); i
++) {
174 fprintf(fp
,"%10g %10g %10g\n",t
,harea
,totarea
);
181 } while (read_next_x(status
,&t
,natoms
,x
,box
));
183 fprintf(stderr
,"\n");
189 int main(int argc
,char *argv
[])
191 static char *desc
[] = {
192 "g_sas computes hydrophobic and total solvent accessible surface area."
195 static real solsize
= 0.14;
196 static int ndots
= 24,nskip
=1;
197 static real qcut
= 0.2;
199 { "-solsize", FALSE
, etREAL
, {&solsize
},
200 "Radius of the solvent probe (nm)" },
201 { "-ndots", FALSE
, etINT
, {&ndots
},
202 "Number of dots per sphere, more dots means more accuracy" },
203 { "-qmax", FALSE
, etREAL
, {&qcut
},
204 "The maximum charge (e, absolute value) of a hydrophobic atom" },
205 { "-skip", FALSE
, etINT
, {&nskip
},
206 "Do only every nth frame" }
209 { efTRX
, "-f", NULL
, ffREAD
},
210 { efTPX
, "-s", NULL
, ffREAD
},
211 { efXVG
, "-o", "area", ffWRITE
},
212 { efPDB
, "-q", "connelly", ffOPTWR
}
214 #define NFILE asize(fnm)
216 CopyRight(stderr
,argv
[0]);
217 parse_common_args(&argc
,argv
,PCA_CAN_VIEW
| PCA_CAN_TIME
,TRUE
,
218 NFILE
,fnm
,asize(pa
),pa
,asize(desc
),desc
,0,NULL
);
221 fprintf(stderr
,"Solsize too small, setting it to %g\n",solsize
);
225 fprintf(stderr
,"Ndots too small, setting it to %d\n",ndots
);
228 sas_plot(NFILE
,fnm
,solsize
,ndots
,qcut
,nskip
);
230 xvgr_file(opt2fn("-o",NFILE
,fnm
),"-nxy");