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
58 #include "gmx_fatal.h"
63 static gmx_bool *bPhobics(int nres, char *resnm[])
69 nb = get_strings("phbres.dat", &cb);
72 for (i = 0; (i < nres); i++)
74 if (search_str(nb, cb, resnm[i]) != -1)
82 void wheel(const char *fn, int nres, char *resnm[], int r0, real rot0, char *title)
84 const real fontsize = 16;
85 const real gray = 0.9;
86 const real fontasp = 0.6;
87 const real fontwidth = fontsize*fontasp;
91 real ring, inner, outer;
100 for (i = 0; (i < nres); i++)
103 sl = strlen(resnm[i]);
104 sign = resnm[i][sl-1];
105 if ((sign == '+') || (sign == '-'))
107 resnm[i][sl-1] = '\0';
109 sprintf(rnms[i], "%s-%d", resnm[i], i+r0);
110 if ((sign == '+') || (sign == '-'))
112 sl = strlen(rnms[i]);
114 rnms[i][sl+1] = '\0';
117 slen = max(slen, (int)strlen(rnms[i]));
119 ring = (2+slen)*fontwidth;
121 box = inner*1.5+(1+(nres / 18))*ring;
123 bPh = bPhobics(nres, resnm);
125 out = ps_open(fn, 0, 0, 2.0*box, 2.0*box);
129 ps_font(out, efontHELV, 1.5*fontsize);
130 ps_translate(out, xc, yc);
133 ps_ctext(out, 0, -fontsize*1.5/2.0, title, eXCenter);
135 ps_font(out, efontHELV, fontsize);
136 ps_rotate(out, rot0);
137 for (i = 0; (i < nres); )
141 ps_color(out, gray, gray, gray);
142 ps_fillarcslice(out, 0, 0, inner, outer, -10, 10);
143 ps_color(out, 0, 0, 0);
145 ps_arcslice(out, 0, 0, inner, outer, -10, 10);
147 ps_ctext(out, inner+fontwidth, -fontsize/2.0, rnms[i], eXLeft);
148 ps_rotate(out, -100);
160 void wheel2(const char *fn, int nres, char *resnm[], int r0, real rot0, char *title)
162 const real fontsize = 14;
163 const real gray = 0.9;
164 const real fontasp = 0.45;
166 const real fontwidth = fontsize*fontasp;
170 real ring, inner, outer;
175 for (i = 0; (i < nres); i++)
177 slen = max(slen, (int)strlen(resnm[i]));
179 fprintf(stderr, "slen = %d\n", slen);
180 ring = (slen)*fontwidth;
182 box = (1+(nres / (2*angle)))*outer;
184 out = ps_open(fn, 0, 0, 2.0*box, 2.0*box);
188 ps_font(out, efontHELV, 1.5*fontsize);
189 ps_translate(out, xc, yc);
190 ps_color(out, 0, 0, 0);
193 ps_ctext(out, 0, -fontsize*1.5/2.0, title, eXCenter);
195 ps_font(out, efontHELV, fontsize);
197 ps_rotate(out, rot0);
198 for (i = 0; (i < nres); )
202 ps_color(out, gray, gray, 1.0);
203 ps_fillarcslice(out, 0, 0, inner, outer, -angle, angle);
204 ps_color(out, 0, 0, 0);
206 ps_arcslice(out, 0, 0, inner, outer, -angle, angle);
208 ps_ctext(out, inner+fontwidth, -fontsize/2.0, resnm[i], eXLeft);
209 ps_rotate(out, -2*angle);
212 if ((i % (2*angle)) == 0)
221 int gmx_wheel(int argc, char *argv[])
223 const char *desc[] = {
224 "[TT]g_wheel[tt] plots a helical wheel representation of your sequence.",
225 "The input sequence is in the [TT].dat[tt] file where the first line contains",
226 "the number of residues and each consecutive line contains a residue "
230 static real rot0 = 0;
231 static gmx_bool bNum = TRUE;
232 static char *title = NULL;
235 { "-r0", FALSE, etINT, {&r0},
236 "The first residue number in the sequence" },
237 { "-rot0", FALSE, etREAL, {&rot0},
238 "Rotate around an angle initially (90 degrees makes sense)" },
239 { "-T", FALSE, etSTR, {&title},
240 "Plot a title in the center of the wheel (must be shorter than 10 characters, or it will overwrite the wheel)" },
241 { "-nn", FALSE, etBOOL, {&bNum},
245 { efDAT, "-f", NULL, ffREAD },
246 { efEPS, "-o", NULL, ffWRITE }
248 #define NFILE asize(fnm)
253 parse_common_args(&argc, argv, PCA_BE_NICE, NFILE, fnm, asize(pa), pa,
254 asize(desc), desc, 0, NULL, &oenv);
256 for (i = 1; (i < argc); i++)
258 if (strcmp(argv[i], "-r0") == 0)
260 r0 = strtol(argv[++i], NULL, 10);
261 fprintf(stderr, "First residue is %d\n", r0);
263 else if (strcmp(argv[i], "-rot0") == 0)
265 rot0 = strtod(argv[++i], NULL);
266 fprintf(stderr, "Initial rotation is %g\n", rot0);
268 else if (strcmp(argv[i], "-T") == 0)
270 title = strdup(argv[++i]);
271 fprintf(stderr, "Title will be '%s'\n", title);
273 else if (strcmp(argv[i], "-nn") == 0)
276 fprintf(stderr, "No residue numbers\n");
280 gmx_fatal(FARGS, "Incorrect usage of option %s", argv[i]);
284 nres = get_lines(ftp2fn(efDAT, NFILE, fnm), &resnm);
287 wheel(ftp2fn(efEPS, NFILE, fnm), nres, resnm, r0, rot0, title);
291 wheel2(ftp2fn(efEPS, NFILE, fnm), nres, resnm, r0, rot0, title);