3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Green Red Orange Magenta Azure Cyan Skyblue
48 int main(int argc
,char *argv
[])
50 const char *desc
[] = {
51 "sas2mat converts matrix data in [IT]raw[it] format to X PixMap format,",
52 "which can be digested by xpm2ps to make nice plots.",
53 "These [IT]raw[it] data may be generated by g_rms, do_dssp or your",
55 "The program prompts the user for some parameters:[PAR]",
56 "[TT]Enter nres, res0, nframes, dt, t0, nlevels:[tt][PAR]",
57 "In this context nres is the number of residues, res0 the starting residue",
58 "dt is the time step, t0 is the starting time, nlevels is the number",
59 "of levels for coloring. By default a greyscale colormap is generated."
61 static bool bCol
=FALSE
;
62 static char *title
="Area (nm^2)";
63 static real ssmin
=-1,ssmax
=-1,t0
=0,dt
=1;
64 static int nres
=1,nframes
=1,r0
=0,nlevels
=20,nskip
=0;
66 { "-col", FALSE
, etBOOL
, &bCol
,
67 "The user is prompted for rgb lower and upper values" },
68 { "-min", FALSE
, etREAL
, &ssmin
,
69 "Lower values for the data, calculated from the data by default" },
70 { "-max", FALSE
, etREAL
, &ssmax
,
71 "Upper values for the data, see above" },
72 { "-title", FALSE
, etSTR
, &title
,
73 "Title for the graph" },
74 { "-nlevel", FALSE
, etINT
, &nlevels
,
75 "Number of levels in graph" },
76 { "-nres", FALSE
, etINT
, &nres
,
77 "Number of residues (Y-axis)" },
78 { "-nframes", FALSE
, etINT
, &nframes
,
79 "Number of frames (Y-axis)" },
80 { "-res0", FALSE
, etINT
, &r0
,
81 "Number of first residue" },
82 { "-nskip", FALSE
, etINT
, &nskip
,
83 "Number of frames to skip after every frame" },
84 { "-dt", FALSE
, etREAL
, &dt
,
85 "Time between time frames" },
86 { "-t0", FALSE
, etREAL
, &t0
,
87 "Time of first time frame" }
93 real
**ss
,lo
,hi
,s1min
,s1max
;
98 { efOUT
, "-f", "area", ffREAD
},
99 { efXPM
, "-o", "sas", ffWRITE
}
101 #define NFILE asize(fnm)
103 /* If we want to read all frames nskip must be greater than zero */
106 CopyRight(stderr
,argv
[0]);
108 parse_common_args(&argc
,argv
,PCA_BE_NICE
,NFILE
,fnm
,asize(pa
),pa
,asize(desc
),desc
,
114 for(i
=0; (i
<nframes
); i
++)
116 for(i
=0; (i
<nres
); i
++) {
119 in
=ftp2FILE(efOUT
,NFILE
,fnm
,"r");
120 for(i
=k
=0; (i
<nframes
); i
++) {
121 for(j
=0; (j
<nres
); j
++) {
125 if (!nskip
|| ((i
% nskip
) == 0))
133 for(j
=0; (j
<nres
); j
++) {
134 /* Find lowest SAS value and subtract that from all occurrences */
137 for(i
=0; (i
<nframes
); i
++) {
138 s1min
=min(s1min
,ss
[j
][i
]);
139 s1max
=max(s1max
,ss
[j
][i
]);
141 printf("res %d: ssmin=%g, ssmax=%g, diff=%g\n",j
,s1min
,s1max
,s1max
-s1min
);
145 printf("Lowest and Highest SAS value: %g %g\n",lo
,hi
);
154 for(j=0; (j<nres); j++) {
155 for(i=0; (i<nframes); i++)
161 rhi
.r
=0,rhi
.g
=0,rhi
.b
=0;
162 rlo
.r
=1,rlo
.g
=1,rlo
.b
=1;
164 printf("Color entries:\n""drlo glo blo rhi ghi bhi\n");
165 scanf("%f%f%f%f%f%f",&rlo
.r
,&rlo
.g
,&rlo
.b
,&rhi
.r
,&rhi
.g
,&rhi
.b
);
168 write_mapfile(ftp2fn(efMAP,NFILE,fnm),&nlevels,rlo,rhi,ssmin,ssmax);
173 out
=ftp2FILE(efXPM
,NFILE
,fnm
,"w");
175 write_matrix(out,nres,nframes,resnr,t,ss,NULL,title,0,hi,nlevels);
177 write_xpm(out
,0,"????","????","Time (ps)","Residue",
178 nres
,nframes
,resnr
,t
,ss
,ssmin
,ssmax
,rlo
,rhi
,&nlevels
);