/* * Removes a single match object and replots. */ void obj_remove(Tcl_Interp *interp, char *cs_plot, obj_match *obj, mobj_repeat *r, HTablePtr T[]) { DeleteRepeats(interp, r, cs_plot, T); /* Sorry about the arithmetic! I'm feeling terse today */ memmove(obj, obj+1, (--r->num_match - (obj - r->match)) * sizeof(*obj)); if (r->num_match > 0) { PlotRepeats(r->io, r); } else { csmatch_remove(r->io, cs_plot, r, T); } }
/* * Handle a REG_JOIN_TO request for match objects * 'r' isn't always a mobj_repeat, but sometimes a mobj_template or * mobj_fij. For the time being though these are all equivalent. */ void csmatch_join_to(GapIO *io, int contig, reg_join *j, mobj_repeat *r, HTablePtr T[], char *cs_plot) { int i; /* printf("Joining %d to %d at offset %d\n", contig, j->contig, j->offset); */ for (i = 0; i < r->num_match; i++) { if (abs(r->match[i].c1) == contig) { r->match[i].pos1 += j->offset; r->match[i].c1 = r->match[i].c1 > 0 ? j->contig : -j->contig; } if (abs(r->match[i].c2) == contig) { r->match[i].pos2 += j->offset; r->match[i].c2 = r->match[i].c2 > 0 ? j->contig : -j->contig; } /* For FIJ: remove match if moved onto diagonal */ if (r->match_type == REG_TYPE_FIJ && r->match[i].c1 == r->match[i].c2) { obj_match *o = &r->match[i]; if (i <= r->current) r->current--; i--; memmove(o, o+1, (--r->num_match - (o - r->match)) * sizeof(*o)); } } if (r->num_match > 0) { DeleteRepeats(GetInterp(), r, cs_plot, T); PlotRepeats(io, r); } else { csmatch_remove(io, cs_plot, r, T); } return; }
void check_assembly_callback(GapIO *io, tg_rec contig, void *fdata, reg_data *jdata) { mobj_checkass *r = (mobj_checkass *)fdata; obj_cs *cs; int cs_id; cs_id = type_to_result(io, REG_TYPE_CONTIGSEL, 0); cs = result_data(io, cs_id); switch (jdata->job) { case REG_QUERY_NAME: sprintf(jdata->name.line, "Check Assembly"); break; case REG_JOIN_TO: csmatch_join_to(io, contig, &jdata->join, (mobj_repeat *)r, csplot_hash, cs->window); break; case REG_COMPLEMENT: csmatch_complement(io, contig, (mobj_repeat *)r, csplot_hash, cs->window); break; case REG_GET_OPS: if (r->all_hidden) jdata->get_ops.ops = "PLACEHOLDER\0PLACEHOLDER\0Information\0" "PLACEHOLDER\0Hide all\0Reveal all\0Sort Matches\0" "SEPARATOR\0Remove\0"; else jdata->get_ops.ops = "Use for 'Next'\0Reset 'Next'\0Information\0" "Configure\0Hide all\0Reveal all\0Sort Matches\0" "SEPARATOR\0Remove\0"; break; case REG_INVOKE_OP: switch (jdata->invoke_op.op) { case 0: /* Next */ Tcl_VarEval(GetInterp(), "CSLastUsed ", CPtr2Tcl(r), NULL); break; case 1: /* Reset Next */ csmatch_reset_next((mobj_repeat *)r); break; case 2: /* Information */ csmatch_info((mobj_repeat *)r, "Check Assembly"); break; case 3: /* Configure */ csmatch_configure(io, cs->window, (mobj_repeat *)r); break; case 4: /* Hide all */ csmatch_hide(GetInterp(), cs->window, (mobj_repeat *)r, csplot_hash); break; case 5: /* Reveal all */ csmatch_reveal(GetInterp(), cs->window, (mobj_repeat *)r, csplot_hash); break; case 6: /* Sort */ qsort(r->match, r->num_match, sizeof(obj_checkass), sort_func); csmatch_reset_hash(csplot_hash, (mobj_repeat *)r); r->current = -1; break; case 7: /* Remove */ csmatch_remove(io, cs->window, (mobj_repeat *)r, csplot_hash); break; } break; case REG_PARAMS: jdata->params.string = r->params; break; case REG_NUMBER_CHANGE: csmatch_renumber(io, contig, jdata->number.number, (mobj_repeat *)r, csplot_hash, cs->window); break; case REG_ORDER: csmatch_replot(io, (mobj_repeat *)r, csplot_hash, cs->window); break; case REG_QUIT: csmatch_remove(io, cs->window, (mobj_repeat *)r, csplot_hash); break; case REG_DELETE: csmatch_contig_delete(io, (mobj_repeat *)r, contig, cs->window, csplot_hash); break; case REG_LENGTH: csmatch_replot(io, (mobj_repeat *)r, csplot_hash, cs->window); break; } }