int
contig_comparator_reg(Tcl_Interp *interp,
		      GapIO *io,
		      obj_cs *cs,
		      char *csp_win,
		      char *csv_win)
{
    int id;
    id = register_id();

    strcpy(cs->hori, cs->window);
    strcpy(cs->vert, csv_win);
    strcpy(cs->window, csp_win);

    /* create list of windows in the contig selector display */
    deleteWindow(cs->win_list, &cs->num_wins, cs->win_list[0]->window);
    addWindow(cs->win_list, &cs->num_wins, cs->window, 'b', id);
    addWindow(cs->win_list, &cs->num_wins, cs->hori,   'x', id);
    addWindow(cs->win_list, &cs->num_wins, cs->vert,   'y', id);

    /* do the first plot */
    update_contig_comparator(interp, io, cs);

/*
    for (i = 1; i <= NumContigs(io); i++) {
	contig_register(io, i, cs_callback, (void *)cs, id,
			REG_REQUIRED | REG_DATA_CHANGE | REG_OPS |
			REG_NUMBER_CHANGE | REG_ANNO | REG_GENERIC |
			REG_BUFFER | REG_FLAG_INVIS, REG_TYPE_CONTIGSEL);
    }
*/
    return id;
}
Exemple #2
0
int main() {
	int key, menuitem, ent, id;
	menuitem = 0;
	initscr();
	drawmenu(menuitem);
	keypad(stdscr,TRUE);
	
	noecho();
	do {
		key = getch();
		switch(key) {
			case KEY_DOWN: menuitem++;
			if(menuitem > MENUMAX-1) 
				menuitem = 0;
			break;

			case KEY_UP: menuitem--;
			if(menuitem < 0) 
				menuitem = MENUMAX-1;
			break;

			default: 
			break;

		}

		drawmenu(menuitem);
		
		ent = getch();
	
		if(menuitem == 0 && ent == KEY_RIGHT) { 
			login();
			refresh();
		}
		else if(menuitem == 1 && ent == KEY_RIGHT) {
			register_id();
			refresh();
		}
		else if(menuitem == 2 && ent == KEY_RIGHT) { 
			findtrain();
			refresh();
		}
		else if(menuitem == 3 && ent == KEY_RIGHT) { 
			printw("Enter train id\n");			
			scanw("%d", &id);
			CheckAvailibility(id);
			refresh();
		}	
		else if(menuitem == 4 && ent == KEY_RIGHT) { 
			cancelticket();
			refresh();
		}
		else if(menuitem == 5 && ent == KEY_RIGHT) { 
			DisplayQueueac();
			refresh();
		}
		else if(menuitem == 6 && ent == KEY_RIGHT) { 
			DisplayQueuesl();
			refresh();
		}
		else if(menuitem == 7 && ent == KEY_RIGHT) { 
			exit(1);
		}
	}	
	while(key != '\n');
		echo();      /*Shows the text*/
	
	endwin();
	return 0;

}
Exemple #3
0
 error_code_mgr()
 {
     auto err = register_id("ERR_OK"); // make sure ERR_OK is always registered first
     dassert(0 == err, "");
 }
void
cs_callback(GapIO *io, int contig, void *fdata, reg_data *jdata) {
    char cmd[1024];
    obj_cs *cs = (obj_cs *)fdata;

    switch(jdata->job) {
    case REG_BUFFER_START:
	{
#ifdef DEBUG
	    printf("REG_BUFFER_START count %d \n", cs->buffer_count);
#endif
	    cs->buffer_count++;
	    cs->do_update = REG_BUFFER_START;
	    return;
	}
    case REG_BUFFER_END:
	{
#ifdef DEBUG
	    printf("REG_BUFFER_END count %d \n", cs->buffer_count);
#endif
	    cs->buffer_count--;
	    if (cs->buffer_count <= 0) {
		cs->buffer_count = 0;
		if (cs->do_update & REG_LENGTH) {

		} else if (cs->do_update & REG_ANNO) {
		    Tcl_VarEval(GetInterp(), cs->hori, " delete tag", NULL);
		    display_cs_tags(GetInterp(), io, cs);
		    scaleSingleCanvas(GetInterp(), cs->world, cs->canvas,
				      cs->hori, 'x', "tag");
		} else if (cs->do_update & REG_ORDER) {
		    update_contig_selector(GetInterp(), io, cs);
		    if (cs->vert[0] != '\0') {
			update_contig_comparator(GetInterp(), io, cs);
		    }
		}
		cs->do_update = 0;
	    }
	    return;
	}
    case REG_QUERY_NAME:
	{
	    sprintf(jdata->name.line, "Contig selector");
	    return;
	}

    case REG_GET_OPS:
	{
	    /* jdata->get_ops.ops = "Information\0Configure\0"; */
	    return;
	}
    case REG_ANNO:
	{
#ifdef DEBUG
	    printf("contig selector REG_ANNO\n");
#endif
	    if (!cs->do_update) {
		Tcl_VarEval(GetInterp(), cs->hori, " delete tag", NULL);
		display_cs_tags(GetInterp(), io, cs);
		scaleSingleCanvas(GetInterp(), cs->world, cs->canvas,
				  cs->hori, 'x', "tag");
	    } else {
		cs->do_update |= REG_ANNO;
	    }
	    return;
	}
    case REG_ORDER:
	{

#ifdef DEBUG
	    printf("contig selector REG_ORDER %d\n", cs->buffer_count);
#endif
	    if (!cs->do_update) {

		update_contig_selector(GetInterp(), io, cs);
		if (cs->vert[0] != '\0') {
		    update_contig_comparator(GetInterp(), io, cs);
		}
	    } else {
		cs->do_update |= REG_ORDER;
	    }
	    break;
	}
    case REG_QUIT:
	{
	    cs_shutdown(io, cs);
	    return;
	}

    case REG_GENERIC:
	switch(jdata->generic.task) {

	case TASK_WINDOW_ADD:
	    {
		win *winfo = (win *)jdata->generic.data;

		addWindow(cs->win_list, &cs->num_wins, winfo->window,
			  winfo->scroll, winfo->id);
		break;
	    }
	case TASK_WINDOW_DELETE:
	    {
		char *window = (char *)jdata->generic.data;

		deleteWindow(cs->win_list, &cs->num_wins, window);
		break;
	    }
	case TASK_CANVAS_SCROLLX:
	    {
		char *scroll = (char *)jdata->generic.data;

		canvasScrollX(GetInterp(), cs->window, cs->win_list,
			      cs->num_wins, cs->world->visible, cs->canvas,
			      scroll);
		break;
	    }
	case TASK_CANVAS_SCROLLY:
	    {
		char *scroll = (char *)jdata->generic.data;

		canvasScrollY(GetInterp(), cs->window, cs->win_list,
			      cs->num_wins, cs->world->visible, cs->canvas,
			      scroll);

		break;
	    }
	case TASK_CANVAS_RESIZE:
	    {
		char scroll_args[20];
		/* resize template display window */
		resizeCanvas(GetInterp(), cs->window, cs->win_list,
			     cs->num_wins, cs->world->visible,
			     cs->world->total, cs->canvas);
		sprintf(scroll_args, "scroll 0 units");
		canvasScrollX(GetInterp(), cs->window, cs->win_list,
			      cs->num_wins, cs->world->visible, cs->canvas,
			      scroll_args);

		break;
	    }
	case TASK_CANVAS_ZOOMBACK:
	    {

		if (lengthZoom(cs->zoom) <= 2) {
		    freeZoom(&cs->zoom);
		    pushZoom(&cs->zoom, cs->world->total);
		}

		canvasZoomback(GetInterp(), cs->canvas, cs->window, cs->world,
			       cs->win_list, cs->num_wins, &cs->zoom);

		break;
		}
	case TASK_CANVAS_ZOOM:
	    {
		s_zoom *szoom = (s_zoom *)jdata->generic.data;
		canvasZoom(GetInterp(), cs->canvas, cs->window, cs->world,
			   cs->win_list, cs->num_wins, &cs->zoom, szoom->zoom,
			   szoom->scroll);

		break;
	    }
	case TASK_CANVAS_CURSOR_X:
	    {
		char *label;
		int *cx = (int *)jdata->generic.data;
		double local_pos;
		double wx, wy;

		CanvasToWorld(cs->canvas, *cx, 0, &wx, &wy);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR1_X");

		canvasCursorX(GetInterp(), cs->canvas, cs->frame, label,
			      cs->cursor.colour, cs->cursor.width, *cx, wx,
			      cs->win_list, cs->num_wins);

		/* fill in local position of cursor in label box */
		local_pos = CSLocalCursor(io, wx);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR2_X");

		sprintf(cmd, "%s%s configure -text %d\n", cs->frame, label,
			(int)local_pos);
		Tcl_Eval(GetInterp(), cmd);

		break;
	    }
	case TASK_CANVAS_CURSOR_Y:
	    {
		char *label;
		int *cy = (int *)jdata->generic.data;
		double local_pos;
		double wx, wy;
		char cmd[1024];
		double cx1, cy1;

		CanvasToWorld(cs->canvas, 0, *cy, &wx, &wy);
		WorldToCanvas(cs->canvas, wy, 0, &cx1, &cy1);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR1_Y");

		canvasCursorY(GetInterp(), cs->canvas, cs->frame, label,
			      cs->cursor.colour, cs->cursor.width, *cy, wy,
			      cs->win_list, cs->num_wins);

		sprintf(cmd, "DrawCanvasCursorX1 %s %s %.20f %s %d\n",
			cs->frame, cs->hori, cx1, cs->cursor.colour,
			cs->cursor.width);
		if (TCL_ERROR == Tcl_Eval(GetInterp(), cmd))
		    printf("%s\n", GetInterpResult());

		/* fill in local position of cursor in label box */
		local_pos = CSLocalCursor(io, wy);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR2_Y");

		sprintf(cmd, "%s%s configure -text %d\n", cs->frame, label,
			(int)local_pos);
		Tcl_Eval(GetInterp(), cmd);

		break;
	    }
	case TASK_CANVAS_CURSOR_DELETE:
	    {
		int i;
		for (i = 0; i < cs->num_wins; i++) {
		    Tcl_VarEval(GetInterp(), cs->win_list[i]->window,
				" delete cursor_x cursor_x1 cursor_y", NULL);
		}
		break;
	    }
	case TASK_CS_REDRAW:
	    {
		/* HACK - never used */
		int i, id = register_id();

		for (i = 1; i <= NumContigs(io); i++) {
		    contig_deregister(io, i, cs_callback, fdata);
		    contig_register(io, i, cs_callback, fdata, id,
				    REG_REQUIRED |
				    REG_DATA_CHANGE |
				    REG_OPS |
				    REG_NUMBER_CHANGE |
				    REG_ANNO |
				    REG_GENERIC |
				    REG_FLAG_INVIS |
				    REG_BUFFER,
				    REG_TYPE_CONTIGSEL);
		}
		break;
	    }
	    break;
	}
	break;
    case REG_JOIN_TO:
    case REG_LENGTH:
    case REG_DELETE:
    case REG_COMPLEMENT:
    case REG_NUMBER_CHANGE:
#ifdef DEBUG
	printf("contig selector REG_REDRAW %d\n", cs->buffer_count);
#endif
	update_contig_selector(GetInterp(), io, cs);
	if (cs->vert[0] != '\0') {
	    update_contig_comparator(GetInterp(), io, cs);
	}
	/* update tcl globals, CurContig, LREG and RREG */
	sprintf(cmd, "ContigParams %d", *handle_io(io));
	Tcl_Eval(GetInterp(), cmd);


#ifdef HACK
	printf("COM %s \n", cs->com);
	if (cs->buffer_count) {
	    cs->do_update = 1;
	} else {
	    Tcl_Eval(cs->interp, cs->com);
	}
#endif
	break;
    }
}
int
contig_selector_reg(Tcl_Interp *interp,
		    GapIO *io,
		    char *frame,
		    char *csh_win,
		    tag_s tag,
		    cursor_s cursor,
		    tick_s *tick)
{
    obj_cs *cs;
    int id;
    int i;

    if (NULL == (cs = (obj_cs *)xmalloc(sizeof(obj_cs))))
	return 0;

    id = register_id();

    cs->line_width = get_default_int(interp, gap_defs,
				     "CONTIG_SEL.LINE_WIDTH");

    cs->line_colour = get_default_astring(interp, gap_defs,
					  "CONTIG_SEL.COLOUR");

/*
    cs->tag = tag_struct(interp, "CONTIG_SEL");
    cs->cursor = cursor_struct(interp, "CONTIG_SEL");
    cs->tick = tick_struct(interp, "CONTIG_SEL");
*/
    cs->tag = tag;
    cs->cursor = cursor;
    cs->tick = tick;
    cs->buffer_count = 0;
    cs->do_update = 0;

    cs->vert[0] = '\0';
    strcpy(cs->frame, frame);
    strcpy(cs->window, csh_win);
    strcpy(cs->hori, cs->window);

    /* create list of windows in the contig selector display */
    if (NULL == (cs->win_list = (win **)xmalloc(MAX_NUM_WINS * sizeof(win*))))
	return -1;
    cs->num_wins = 0;
    addWindow(cs->win_list, &cs->num_wins, cs->window, 'x', id);

    if (NULL == (cs->canvas = (CanvasPtr *)xmalloc(sizeof(CanvasPtr))))
	return -1;

    if (NULL == (cs->world= (WorldPtr *)xmalloc(sizeof(WorldPtr))))
	return -1;

    if (NULL == (cs->world->visible = (d_box *)xmalloc(sizeof(d_box))))
	return -1;

    if (NULL == (cs->world->total = (d_box *)xmalloc(sizeof(d_box))))
	return -1;

    initCanvas(interp, cs->canvas, cs->window);
    createZoom(&cs->zoom);

    /* do the first plot */
    update_contig_selector(interp, io, cs);

    for (i = 1; i <= NumContigs(io); i++) {
	contig_register(io, i, cs_callback, (void *)cs, id,
			REG_REQUIRED | REG_DATA_CHANGE | REG_OPS |
			REG_NUMBER_CHANGE | REG_ANNO | REG_GENERIC |
			REG_BUFFER | REG_ORDER | REG_FLAG_INVIS, REG_TYPE_CONTIGSEL);
    }
    return id;

}
int check_assembly_plot(GapIO *io, tg_rec *reads, tg_rec *conts, int *score,
			int *pos, int *length, int count) {
    int i, id;
    mobj_checkass *ca;
    obj_checkass *matches;
    char *val;

    if (count == 0)
	return 0;

    if (NULL == (ca = (mobj_checkass *)xmalloc(sizeof(mobj_checkass)))) {
	return -1;
    }

    if (NULL == (matches = (obj_checkass *)xmalloc(count *
						   sizeof(obj_checkass)))) {
	xfree(ca);
	return -1;
    }

    /* Setup the meta-object */
    ca->num_match = count;
    ca->match = (obj_match *)matches;
    ca->io = io;
    ca->cutoffs = 0;
    strcpy(ca->tagname, CPtr2Tcl(ca));

    val = get_default_string(GetInterp(), gap5_defs, "CHECK_ASSEMBLY.COLOUR");
    strcpy(ca->colour, val);
    ca->linewidth = get_default_int(GetInterp(), gap5_defs,
				    "CHECK_ASSEMBLY.LINEWIDTH");

    ca->params = (char *)xmalloc(100);
    if (ca->params)
	sprintf(ca->params, "Unknown at present");
    ca->all_hidden = 0;
    ca->current = -1;
    ca->current = -1;
    ca->reg_func = check_assembly_callback;
    ca->match_type = REG_TYPE_CHECKASS;

    /* Set up each object */
    for (i=0; i<count; i++) {
	matches[i].func = (void *(*)(int, void *, struct obj_match_t *,
				    struct mobj_repeat_t *))checkass_obj_func;
	matches[i].data = (mobj_repeat *)ca;
	matches[i].c1 = matches[i].c2 = conts[i];
	matches[i].pos1 = matches[i].pos2 = pos[i];
	matches[i].end1 = matches[i].end2 = pos[i] + length[i];
	matches[i].length = length[i];
	matches[i].score = score[i];
	matches[i].flags = 0;
	matches[i].read = reads[i];
    }

    /* Sort matches */
    qsort(ca->match, ca->num_match, sizeof(obj_match), sort_func);

    PlotRepeats(io, (mobj_repeat *)ca);
    Tcl_VarEval(GetInterp(), "CSLastUsed ", CPtr2Tcl(ca), NULL);

    /*
     * Register the repeat search with each of the contigs used.
     * Currently we assume that this is all.
     */
    id = register_id();
    contig_register(io, 0, check_assembly_callback, (void *)ca, id,
		    REG_REQUIRED | REG_DATA_CHANGE | REG_OPS |
		    REG_NUMBER_CHANGE | REG_ORDER, REG_TYPE_CHECKASS);
    update_results(io);

    return 0;
}
void
plot_rpt(GapIO *io,
	 int nres,
	 int c1[],
	 int pos1[],
	 int c2[],
	 int pos2[],
	 int len[])
{
    int i, id;
    mobj_repeat *repeat;
    obj_match *matches = NULL;
    char *val;

    /* If nres is zero - do nothing */
    if (0 == nres)
	return;

    if (NULL == (repeat = (mobj_repeat *)xmalloc(sizeof(mobj_repeat)))) {
	f_proc_return();
    }

    if (NULL == (matches = (obj_match *)xmalloc(nres * sizeof(obj_match)))) {
	xfree(repeat);
	f_proc_return();
    }

    repeat->num_match = nres;
    repeat->match = matches;
    repeat->io = io;
    strcpy(repeat->tagname, CPtr2Tcl(repeat));

    val = get_default_string(GetInterp(), gap_defs,"FINDREP.COLOUR");
    strcpy(repeat->colour, val);

    repeat->linewidth = get_default_int(GetInterp(), gap_defs,
					"FINDREP.LINEWIDTH");

    repeat->params = (char *)xmalloc(100);
    if (repeat->params)
	sprintf(repeat->params, "Unknown at present");
    repeat->all_hidden = 0;
    repeat->current = -1;
    repeat->reg_func = repeat_callback;
    repeat->match_type = REG_TYPE_REPEAT;

    /* Create and plot our match array */
    for (i= 0; i < nres; i++){
	matches[i].func = repeat_obj_func;
	matches[i].data = repeat;
        matches[i].c1 = rnumtocnum(io, ABS(c1[i])) * (c1[i] < 1 ? -1 : 1);
        matches[i].pos1 = pos1[i];
        matches[i].c2 = rnumtocnum(io, ABS(c2[i])) * (c2[i] < 1 ? -1 : 1);
        matches[i].pos2 = pos2[i];
        matches[i].length = len[i];
        matches[i].score = 0;
	matches[i].flags = 0;
    }

    /* Sort matches */
    qsort(repeat->match, repeat->num_match, sizeof(obj_match), sort_func);

    PlotRepeats(io, repeat);
    Tcl_VarEval(GetInterp(), "CSLastUsed ", CPtr2Tcl(repeat), NULL);

    /*
     * Register the repeat search with each of the contigs used.
     * Currently we assume that this is all.
     */
    id = register_id();
    for (i = 1; i <= NumContigs(io); i++) {
	contig_register(io, i, repeat_callback, (void *)repeat, id,
			REG_REQUIRED | REG_DATA_CHANGE | REG_OPS |
			REG_NUMBER_CHANGE | REG_ORDER, REG_TYPE_REPEAT);
    }
}
Exemple #8
0
int
RegFindOligo(GapIO *io,
	     int type,
	     int *pos1,
	     int *pos2,
	     int *score,
	     int *length,
	     tg_rec *c1,
	     tg_rec *c2,
	     int n_matches)
{
    mobj_find_oligo *find_oligo;
    obj_match *matches = NULL;
    char *val;
    int i, id;

    if (0 == n_matches)
	return 0;

    if (NULL == (find_oligo = (mobj_find_oligo *)xmalloc(sizeof(mobj_find_oligo))))
	return -1;

    if (NULL == (matches = (obj_match *)xmalloc(n_matches * sizeof(obj_match))))
	return -1;

    find_oligo->num_match = n_matches;
    find_oligo->match = matches;
    find_oligo->io = io;
    strcpy(find_oligo->tagname, CPtr2Tcl(find_oligo));

    val = get_default_string(GetInterp(), gap5_defs, "FINDOLIGO.COLOUR");
    strcpy(find_oligo->colour, val);

    find_oligo->linewidth = get_default_int(GetInterp(), gap5_defs,
					    "FINDOLIGO.LINEWIDTH");

    find_oligo->params = (char *)xmalloc(100);
    if (find_oligo->params)
	sprintf(find_oligo->params, "Unknown at present");
    find_oligo->all_hidden = 0;
    find_oligo->current = -1;
    find_oligo->reg_func = find_oligo_callback;
    find_oligo->match_type = REG_TYPE_OLIGO;

    for (i = 0; i < n_matches; i++) {
	if (type == TAG) {
	    matches[i].func =
		(void *(*)(int, void *, struct obj_match_t *,
			   struct mobj_repeat_t *))find_oligo_obj_func1;
	} else if (type == SEQUENCE) {
	    matches[i].func =
		(void *(*)(int, void *, struct obj_match_t *,
			   struct mobj_repeat_t *))find_oligo_obj_func2;
	} else {
	    return -1;
	}
	matches[i].data = find_oligo;
	matches[i].c1 = c1[i];
	matches[i].c2 = c2[i];
	matches[i].pos1 = pos1[i];
	matches[i].pos2 = pos2[i];
	matches[i].length = length[i];
	matches[i].score = score[i];
	matches[i].flags = 0;
    }

    /* Sort matches */
    qsort(find_oligo->match, find_oligo->num_match, sizeof(obj_match),
	  sort_func);

    PlotRepeats(io, find_oligo);
    Tcl_VarEval(GetInterp(), "CSLastUsed ", CPtr2Tcl(find_oligo), NULL);

    /*
     * Register the find oligo search with each of the contigs used.
     * Currently we assume that this is all.
     */
    id = register_id();
    contig_register(io, 0, find_oligo_callback, (void *)find_oligo, id,
		    REG_REQUIRED | REG_DATA_CHANGE | REG_OPS |
		    REG_NUMBER_CHANGE | REG_ORDER, REG_TYPE_OLIGO);
    update_results(io);

    return 0;
}