void rna_output_descr(toptions *opts, tsequence *seq) { if (seq->descr && seq->descr[0]) { pcolor(opts->colored_output,COLOR_BOLD); printf(">%s", seq->descr); pcolor(opts->colored_output,COLOR_DEFAULT); printf("\n"); } }
void rna_output_optimal(toptions *opts, tsequence *seq, char *algebra, int result_score, int range_begin, int range_end) { if (!opts->window_mode) { printf("\n"); pcolor(opts->colored_output,COLOR_BOLD); printf("%s: ", algebra); printf("%.2f kcal/mol", ((float) result_score) / 100); pcolor(opts->colored_output,COLOR_DEFAULT); printf("\n"); } }
/* print position numbers for sequence; used in window- and split-output modes */ static void print_subseq_numbers(toptions *opts, int pos, int size){ int i; if (opts->split_output_mode) size = min(opts->window_pos + opts->window_size, pos + opts->split_output_size) - pos; pcolor(opts->colored_output, COLOR_BLUE); printf("%d", pos +1); pcolor(opts->colored_output,COLOR_DEFAULT); for (i=1; i<= size - (((int)log10(pos + 1))+1 + ((int)log10(pos + size))+1); i++) printf(" "); pcolor(opts->colored_output,COLOR_BLUE); printf("%d", pos + size); pcolor(opts->colored_output,COLOR_DEFAULT); printf("\n"); }
static PyObject *image_pcolor(PyObject *self, PyObject *args, PyObject *kwds) { numpy::array_view<const float, 1> x; numpy::array_view<const float, 1> y; numpy::array_view<const agg::int8u, 3> d; unsigned int rows; unsigned int cols; float bounds[4]; int interpolation; Image *result; if (!PyArg_ParseTuple(args, "O&O&O&II(ffff)i:pcolor", &x.converter, &x, &y.converter, &y, &d.converter_contiguous, &d, &rows, &cols, &bounds[0], &bounds[1], &bounds[2], &bounds[3], &interpolation)) { return NULL; } CALL_CPP("pcolor", (result = pcolor(x, y, d, rows, cols, bounds, interpolation))); return PyImage_cnew(result); }
Mm ex() { begin_scope #line 1 "d:/matcom45/ex.m" call_stack_begin; #line 1 "d:/matcom45/ex.m" // nargin, nargout entry code double old_nargin=nargin_val; if (!nargin_set) nargin_val=0.0; nargin_set=0; double old_nargout=nargout_val; if (!nargout_set) nargout_val=0.0; nargout_set=0; // translated code #line 2 "d:/matcom45/ex.m" _ subplot(121.0); #line 3 "d:/matcom45/ex.m" _ surf((CL(peaks(25.0)))); #line 4 "d:/matcom45/ex.m" _ subplot(122.0); #line 5 "d:/matcom45/ex.m" _ pcolor((CL(peaks(25.0)))); call_stack_end; // nargin, nargout exit code nargin_val=old_nargin; nargout_val=old_nargout; // function exit code return x_M; end_scope }
void SprayBrush::paintParticle(KisRandomAccessor &writeAccessor,const KoColor &color,qreal rx, qreal ry){ // opacity top left, right, bottom left, right KoColor pcolor(color); int ipx = int ( rx ); int ipy = int ( ry ); qreal fx = rx - ipx; qreal fy = ry - ipy; int btl = qRound( ( 1-fx ) * ( 1-fy ) * OPACITY_OPAQUE ); int btr = qRound( ( fx ) * ( 1-fy ) * OPACITY_OPAQUE ); int bbl = qRound( ( 1-fx ) * ( fy ) * OPACITY_OPAQUE ); int bbr = qRound( ( fx ) * ( fy ) * OPACITY_OPAQUE ); // this version overwrite pixels, e.g. when it sprays two particle next // to each other, the pixel with lower opacity can override other pixel. // Maybe some kind of compositing using here would be cool pcolor.setOpacity ( btl ); writeAccessor.moveTo ( ipx , ipy ); memcpy ( writeAccessor.rawData(), pcolor.data(), m_pixelSize ); pcolor.setOpacity ( btr ); writeAccessor.moveTo ( ipx + 1, ipy ); memcpy ( writeAccessor.rawData(), pcolor.data(), m_pixelSize ); pcolor.setOpacity ( bbl ); writeAccessor.moveTo ( ipx, ipy + 1 ); memcpy ( writeAccessor.rawData(), pcolor.data(), m_pixelSize ); pcolor.setOpacity ( bbr ); writeAccessor.moveTo ( ipx + 1, ipy + 1 ); memcpy ( writeAccessor.rawData(), pcolor.data(), m_pixelSize ); }
void rna_output_subopt_start(toptions *opts, tsequence *seq, char *algebra, int result_score, int range_begin, int range_end) { if (!opts->window_mode && (strcmp(algebra, "count"))) { printf("Suboptimal range: [%.2f kcal/mol - %.2f kcal/mol]\n", ((float) range_begin)/100, ((float) range_end)/100); printf("\n"); if (seq->descr && seq->descr[0]) { pcolor(opts->colored_output,COLOR_BOLD); printf(">%s", seq->descr); pcolor(opts->colored_output,COLOR_DEFAULT); printf("\n"); } if (!opts->split_output_mode) printf("%s\n", seq->original_seq); } // print subsequence for first window iteration // for later iterations, this is done in function shift_input if (opts->window_mode && (opts->window_pos==0) && (strcmp(algebra, "count"))) { print_sequence(opts, seq, opts->window_pos, opts->window_size); } }
static void render_pixels(QPainter &p, gint x, gint width, float rgb[TIMELINE_HEIGHT][3], float ratio) { int previous = 0, i; for (i = 1; i <= TIMELINE_HEIGHT; i++) { if (i != TIMELINE_HEIGHT && rgb[previous][0] == rgb[i][0] && rgb[previous][1] == rgb[i][1] && rgb[previous][2] == rgb[i][2]) continue; if (rgb[previous][0] != 1.0 || rgb[previous][1] != 1.0 || rgb[previous][2] != 1.0) { p.fillRect(QRectF(x/ratio, previous, width/ratio, i-previous), pcolor(rgb[previous][0],rgb[previous][1],rgb[previous][2])); } previous = i; } reset_rgb(rgb); }
void simple_output_optimal(toptions *opts, tsequence *seq, char *algebra, int result_score, int range_begin, int range_end) { printf("\nInput: "); pcolor(opts->colored_output,COLOR_BOLD); printf("%s", seq->seq); pcolor(opts->colored_output,COLOR_DEFAULT); printf("\nAlgebra: "); pcolor(opts->colored_output,COLOR_BOLD); printf("%s", algebra); pcolor(opts->colored_output,COLOR_DEFAULT); printf(", score: "); pcolor(opts->colored_output,COLOR_BOLD); printf("%d\n", result_score); pcolor(opts->colored_output,COLOR_DEFAULT); }
static void render_rectangle(QPainter &p, gint x, gint width, guint height, int dfilter, float r, float g, float b, float ratio) { p.fillRect(QRectF(x/ratio, TIMELINE_HEIGHT/2-height, width/ratio, dfilter ? height * 2 : height), pcolor(r,g,b)); }
static void process_args(toptions *opt, char interactive, int argc, char **argv) { int c; char manopt, manoptmode; opterr = 0; optind = 1; pcolor(opt->colored_output,COLOR_BLUE); while ((c = getopt (argc, argv, "hH:ve:c:M:w:W:BS:f:z:O")) != -1) { switch (c) { // Display this information (-h) case 'h': if (interactive) { printf("Interactive mode:\nEnter sequence directly or use the following commands to change settings:\n"); } else { printf("Options:\n"); } printf(" -h Display this information\n"); printf(" -H <option> Display detailed information on <option>\n"); printf(" -v Show version\n"); printf(" -e <value> Set energy range (kcal/mol)\n"); printf(" -c <value> Set energy range (%%)\n"); printf(" -M <value> Set maximal loop length\n"); printf(" -w <value> Set window size\n"); printf(" -W <value> Set window position increment\n"); printf(" -B Show best results in window mode\n"); printf(" -O Only compute energy, no traceback\n"); printf(" -S <value> Specify output width for structures\n"); printf(" -f <filename> Read input from file\n"); printf(" -z Colored output\n"); if (opt->interactive) { printf("Additional interactive mode commands:\n"); printf(" :s Show current configuration\n"); printf(" :d Reset configuration\n"); printf(" :e <string> Execute system command\n"); printf(" :q Quit\n"); } opt->terminate = 1; break; // Display detailed information on <option> (-H) case 'H': if (optarg[0]=='-') { manoptmode = '-'; manopt = optarg[1]; } else if (optarg[0]==':') { manoptmode = ':'; manopt = optarg[1]; } else { manoptmode = '-'; manopt = optarg[0]; } if (!interactive) printf("\n"); #include "RNAfold-man.c" if (!interactive) printf("\n"); opt->terminate = 1; break; // Show version (-v) case 'v': printf("%s (%s)\n",PACKAGE_STRING,RELEASE_DATE); printf("\n"); opt->terminate = 1; break; // Set energy range (kcal/mol) (-e) case 'e': sscanf(optarg,"%f",&(opt->traceback_diff)); opt->traceback_diff = max(0, opt->traceback_diff); if (interactive) printf("Energy range set to %.2f kcal/mol.\n", opt->traceback_diff); opt->traceback_percent = 0; break; // Set energy range (%%) (-c) case 'c': sscanf(optarg,"%d",&(opt->traceback_percent)); opt->traceback_percent = max(0, opt->traceback_percent); if (interactive) printf("Energy range set to %d%% of mfe.\n", opt->traceback_percent); opt->traceback_diff = 0; break; // Set maximal loop length (-M) case 'M': sscanf(optarg,"%d",&(opt->maxloop)); opt->maxloop = max(0, opt->maxloop); if (interactive) printf("Set maximal loop length to %d.\n", opt->maxloop); break; // Set window size (-w) case 'w': if ((interactive) && (optarg[0] == '-')) { printf("Window mode disabled.\n"); opt->window_mode = 0; } if (optarg[0] != '-') { opt->window_mode = 1; sscanf(optarg,"%d",&(opt->window_size)); opt->window_size = max(1, opt->window_size); if (interactive) printf("Set window size to %d. Type -w - to disable.\n", opt->window_size); } break; // Set window position increment (-W) case 'W': sscanf(optarg,"%d",&(opt->window_step)); opt->window_step = max(1, opt->window_step); if (interactive) printf("Set window position increment to %d.\n", opt->window_step); break; // Show best results in window mode (-B) case 'B': if (interactive) { printf("Show best results in window mode"); opt->window_best = 1 - opt->window_best; if (opt->window_best) printf (" = ON. Type -B again to switch off.\n"); else printf (" = OFF. Type -B again to switch on.\n"); } else opt->window_best = 1; break; // Only compute energy, no traceback (-O) case 'O': opt->energy_only = 1; break; // Specify output width for structures (-S) case 'S': if ((interactive) && (optarg[0] == '-')) { printf("Output splitting disabled.\n"); opt->split_output_mode = 0; } if (optarg[0] != '-') { opt->split_output_mode = 1; sscanf(optarg,"%d",&(opt->split_output_size)); opt->split_output_size = max(1, opt->split_output_size); if (interactive) printf("Set output size to %d. Type -S - to disable.\n", opt->split_output_size); } break; // Read input from file (-f) case 'f': if (opt->inputfile) free(opt->inputfile); opt->inputfile = mkstr(optarg); break; // Colored output (-z) case 'z': if (interactive) { printf("Colored output"); opt->colored_output = 1 - opt->colored_output; if (opt->colored_output) printf (" = ON. Type -z again to switch off.\n"); else printf (" = OFF. Type -z again to switch on.\n"); } else opt->colored_output = 1; if (opt->interactive && !opt->colored_output) printf(COLOR_DEFAULT); break; case '?': if (interactive) printf("Unknown option '-%c'. Type -h for more information.\n", optopt); else { fprintf (stderr, "%s: unknown option `-%c'.\nTry '%s -h' for more information.\n", argv[0], optopt, argv[0]); exit(1); } break; default: abort (); } } pcolor(opt->colored_output,COLOR_DEFAULT); }
int main (int argc, char **argv) { toptions *opt; tsequence *seq; treadseq *rs = NULL; ttokenizer *tokenizer = NULL; char *command; opt = (toptions *) calloc(1,sizeof(toptions)); init_defaults(opt); process_args(opt, 0, argc, argv); if (!opt->terminate) { if (optind < argc) rs = readseq_open(READSEQ_STRING, argv[optind]); else if (opt->inputfile) rs = readseq_open(READSEQ_FILE, opt->inputfile); else if (!isatty(fileno(stdin))) rs = readseq_open(READSEQ_STDIN, NULL); else { printf("Interactive mode. Try `./RNAfold -h` for more information.\n", argv[0]); rl_init(); opt->interactive = 1; opt->colored_output = 1 - opt->colored_output; tokenizer = tokenizer_new(); rs = readseq_open(READSEQ_STRING, ""); } while (1) { if (opt->interactive) { if (opt->colored_output) printf("%s\nInput sequence (upper or lower case); :q to quit, -h for help.\n....,....1....,....2....,....3....,....4....,....5....,....6....,....7....,....8\n%s",COLOR_RED,COLOR_DEFAULT); else printf("\nInput sequence (upper or lower case); :q to quit, -h for help.\n....,....1....,....2....,....3....,....4....,....5....,....6....,....7....,....8\n"); command = rl_gets(); if (!command || (command[0] == '@') || ((command[0] == ':') && (command[1] == 'q'))) { pcolor(opt->colored_output,COLOR_BLUE); printf("Leaving RNAfold."); pcolor(opt->colored_output,COLOR_DEFAULT); printf("\n"); exit(0); } else if (command[0] == ':') { pcolor(opt->colored_output,COLOR_BLUE); if (command[1] == 's') print_settings(opt); if (command[1] == 'd') { init_defaults(opt); opt->colored_output = 1; opt->interactive = 1; printf("Activated default configuration.\n"); pcolor(opt->colored_output,COLOR_DEFAULT); } if (command[1] == 'e') { system(command + 2); } if (command[1] == 'r') { system("make update"); system("./RNAfold"); exit(0); } } else if (command[0] == '-') { tokenizer_exec(tokenizer, argv[0], command); process_args(opt, 1, tokenizer->count, tokenizer->token); if (opt->inputfile) { rs = readseq_free(rs); rs = readseq_open(READSEQ_FILE, opt->inputfile); } free(opt->inputfile); opt->inputfile = NULL; } else { rs = readseq_free(rs); rs = readseq_open(READSEQ_STRING, command); } } while (1) { seq = readseq_next_fasta(rs); if (!(seq->success)) break; if (1) { main_rnafold_mfe(opt, seq); } sequence_free(seq); } if (!opt->interactive) break; } } exit(0); }