4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * Green Red Orange Magenta Azure Cyan Skyblue
32 static char *SRCID_wheel_c
= "$Id$";
54 bool *bPhobics(int nres
,char *resnm
[])
60 nb
=get_strings("phbres.dat",&cb
);
63 for(i
=0; (i
<nres
); i
++) {
64 if (search_str(nb
,cb
,resnm
[i
]) != -1)
70 void wheel(char *fn
,int nres
,char *resnm
[],int r0
,real rot0
,char *title
)
72 const real fontsize
= 16;
73 const real gray
= 0.9;
74 const real fontasp
= 0.6;
75 const real fontwidth
= fontsize
*fontasp
;
79 real ring
,inner
,outer
;
88 for(i
=0; (i
<nres
); i
++) {
92 if ((sign
== '+') || (sign
== '-'))
93 resnm
[i
][sl
-1] = '\0';
94 sprintf(rnms
[i
],"%s-%d",resnm
[i
],i
+r0
);
95 if ((sign
== '+') || (sign
== '-')) {
101 slen
=max(slen
,(int)strlen(rnms
[i
]));
103 ring
=(2+slen
)*fontwidth
;
105 box
=inner
*1.5+(1+(nres
/ 18))*ring
;
107 bPh
=bPhobics(nres
,resnm
);
109 out
=ps_open(fn
,0,0,2.0*box
,2.0*box
);
113 ps_font(out
,efontHELV
,1.5*fontsize
);
114 ps_translate(out
,xc
,yc
);
116 ps_ctext(out
,0,-fontsize
*1.5/2.0,title
,eXCenter
);
117 ps_font(out
,efontHELV
,fontsize
);
119 fprintf(out
,"%g rotate\n",rot0
);
120 for(i
=0; (i
<nres
); ) {
122 ps_color(out
,gray
,gray
,gray
);
123 ps_fillarcslice(out
,0,0,inner
,outer
,-10,10);
126 ps_arcslice(out
,0,0,inner
,outer
,-10,10);
128 ps_ctext(out
,inner
+fontwidth
,-fontsize
/2.0,rnms
[i
],eXLeft
);
129 fprintf(out
,"-100 rotate\n");
140 void wheel2(char *fn
,int nres
,char *resnm
[],int r0
,real rot0
,char *title
)
142 const real fontsize
= 14;
143 const real gray
= 0.9;
144 const real fontasp
= 0.45;
146 const real fontwidth
= fontsize
*fontasp
;
150 real ring
,inner
,outer
;
155 for(i
=0; (i
<nres
); i
++) {
156 slen
=max(slen
,(int)strlen(resnm
[i
]));
158 fprintf(stderr
,"slen = %d\n",slen
);
159 ring
=(slen
)*fontwidth
;
161 box
=(1+(nres
/ (2*angle
)))*outer
;
163 out
=ps_open(fn
,0,0,2.0*box
,2.0*box
);
167 ps_font(out
,efontHELV
,1.5*fontsize
);
168 ps_translate(out
,xc
,yc
);
171 ps_ctext(out
,0,-fontsize
*1.5/2.0,title
,eXCenter
);
172 ps_font(out
,efontHELV
,fontsize
);
174 fprintf(out
,"%g rotate\n",rot0
);
175 for(i
=0; (i
<nres
); ) {
177 ps_color(out
,gray
,gray
,1.0);
178 ps_fillarcslice(out
,0,0,inner
,outer
,-angle
,angle
);
181 ps_arcslice(out
,0,0,inner
,outer
,-angle
,angle
);
183 ps_ctext(out
,inner
+fontwidth
,-fontsize
/2.0,resnm
[i
],eXLeft
);
184 fprintf(out
,"%d rotate\n",-2*angle
);
187 if ((i
% (2*angle
)) == 0) {
195 int main(int argc
,char *argv
[])
197 static char *desc
[] = {
198 "wheel plots a helical wheel representation of your sequence."
199 "The input sequence is in the .dat file where the first line contains",
200 "the number of residues and each consecutive line contains a residue"
204 static bool bNum
=TRUE
;
205 static char *title
=NULL
;
208 { "-r0", FALSE
, etINT
, {&r0
},
209 "The first residue number in the sequence" },
210 { "-rot0",FALSE
, etREAL
,{&rot0
},
211 "Rotate around an angle initially (90 degrees makes sense)" },
212 { "-T", FALSE
, etSTR
, {&title
},
213 "Plot a title in the center of the wheel (must be shorter than 10 characters, or it will overwrite the wheel)" },
214 { "-nn", FALSE
, etBOOL
,{&bNum
},
218 { efDAT
, "-f", NULL
, ffREAD
},
219 { efEPS
, "-o", NULL
, ffWRITE
}
221 #define NFILE asize(fnm)
226 CopyRight(stderr
,argv
[0]);
227 parse_common_args(&argc
,argv
,PCA_BE_NICE
,NFILE
,fnm
,asize(pa
),pa
,
228 asize(desc
),desc
,0,NULL
);
230 for(i
=1; (i
<argc
); i
++) {
231 if (strcmp(argv
[i
],"-r0") == 0) {
233 fprintf(stderr
,"First residue is %d\n",r0
);
235 else if (strcmp(argv
[i
],"-rot0") == 0) {
236 rot0
=atof(argv
[++i
]);
237 fprintf(stderr
,"Initial rotation is %g\n",rot0
);
239 else if (strcmp(argv
[i
],"-T") == 0) {
240 title
=strdup(argv
[++i
]);
241 fprintf(stderr
,"Title will be '%s'\n",title
);
243 else if (strcmp(argv
[i
],"-nn") == 0) {
245 fprintf(stderr
,"No residue numbers\n");
248 fatal_error(0,"Incorrect usage of option %s",argv
[i
]);
251 nres
=get_lines(ftp2fn(efDAT
,NFILE
,fnm
),&resnm
);
253 wheel(ftp2fn(efEPS
,NFILE
,fnm
),nres
,resnm
,r0
,rot0
,title
);
255 wheel2(ftp2fn(efEPS
,NFILE
,fnm
),nres
,resnm
,r0
,rot0
,title
);