/* * ---------------------------------------------------------------------- * Remove Pad Columns. Sometimes we don't want to realign data, we just * want to remove (aligned) columns of pads. * ---------------------------------------------------------------------- */ int remove_pad_columns(GapIO *io, int ncontigs, contig_list_t *contigs, int percent_pad, int quiet) { int i; consensus_t *cons = NULL; size_t max_alloc = 0; for (i = 0; i < ncontigs; i++) { tg_rec cnum = contigs[i].contig; size_t len, j; int ndel = 0; contig_t *c; if (!quiet) { vmessage("Processing contig %d of %d (#%"PRIrec")\n", i+1, ncontigs, cnum); UpdateTextOutput(); } c = cache_search(io, GT_Contig, cnum); if (!c) return -1; cache_incr(io, c); len = contigs[i].end - contigs[i].start + 1; if (max_alloc < len) { max_alloc = len; cons = realloc(cons, max_alloc * sizeof(*cons)); } if (0 != calculate_consensus(io, cnum, contigs[i].start, contigs[i].end, cons)) { free(cons); cache_decr(io, c); return -1; } for (j = 0; j < len; j++) { if (cons[j].call != 4) continue; if (100 * cons[j].counts[4] / cons[j].depth < percent_pad) continue; if (!quiet) vmessage(" Removing column %d %d%% pad (%d of %d), conf. %f)\n", (int)j+contigs[i].start, 100 * cons[j].counts[4] / cons[j].depth, cons[j].counts[4], cons[j].depth, cons[j].scores[cons[j].call]); contig_delete_base(io, &c, contigs[i].start + j - ndel); ndel++; } cache_decr(io, c); } if (cons) free(cons); return 0; }
void curses_loop(GapIO *io, contig_t **cp, int xpos, int mode) { int ypos = 0; int maxy, maxx; int qual_cutoff = 29; #ifdef NCURSES_VERSION getmaxyx(stdscr, maxy, maxx); #else maxx = 80; maxy = 40; #endif if (xpos < (maxx-MAX_NAME_LEN+2)/2) xpos = (maxx-MAX_NAME_LEN+2)/2; display_gap(io, cp, xpos, ypos, maxy, maxx, mode, qual_cutoff, 1); for(;;) { switch (getch()) { case '!': edit_contig_name(io, cp); break; case '"': /* control-x */ save(io); break; case 'd': mode ^= DISPLAY_DIFFS; break; case 'c': mode ^= DISPLAY_CUTOFFS; break; case 'C': mode ^= DISPLAY_COLOURS; break; case 'q': mode ^= DISPLAY_QUAL; break; case 'g': xpos = wgotonum(xpos, gotowin); break; case 'G': { char *seq = wgotoseq(gotowin); tg_rec n; if (seq) { if ((n = sequence_index_query(io, seq)) < 0) { putchar('\a'); fflush(stdout); } else { tg_rec c; int x; sequence_get_position(io, n, &c, &x, NULL, NULL); /* FIXME: check c and *cp are same contig */ xpos = x; } } break; } case '?': whelp(helpwin); break; case '-': qual_cutoff--; break; case '+': qual_cutoff++; break; case 'n': next_contig(io, cp); xpos = ypos = 0; break; case 'p': prev_contig(io, cp); xpos = ypos = 0; break; /* Orthoganol movements */ case KEY_RIGHT: case 'l': xpos++; break; case KEY_SRIGHT: case 'L': xpos+=20; break; case '\014': xpos+=1000; break; case KEY_LEFT: case 'h': xpos--; break; case KEY_SLEFT: case 'H': xpos-=20; break; case KEY_BACKSPACE: case '\010': xpos-=1000; break; case KEY_DOWN: case 'j': ypos++; break; case 'J': ypos+=20; break; case KEY_UP: case 'k': ypos--; break; case 'K': ypos-=20; break; case 'x': return; case '<': xpos = (*cp)->start; break; case '>': xpos = (*cp)->end; break; case 'f': complement_bin(io, contig_get_bin(cp)); break; case 'i': contig_insert_base(io, cp, xpos, '-', 20); break; case 'o': contig_delete_base(io, cp, xpos); break; #ifdef KEY_RESIZE case KEY_RESIZE: getmaxyx(stdscr, maxy, maxx); break; #endif default: continue; } if (xpos < (*cp)->start) xpos = (*cp)->start; if (xpos > (*cp)->end) xpos = (*cp)->end; if (ypos < 0) ypos = 0; display_gap(io, cp, xpos, ypos, maxy, maxx, mode, qual_cutoff, 1); } }