/* * create a random sequence from either dna or protein input sequence * add sequence to sequence manager */ int ScrambleSeq(Tcl_Interp *interp, int seq_num) { char *seq1 = GetSeqSequence(seq_num); int length = GetSeqLength(seq_num); int seq_id = GetSeqId(seq_num); char *seq2; char *name; time_t tim; int seed; char *parental_name, *child_name; int new_seq_num, start, end; static int num = 0; if (NULL == (seq2 = (char *)xmalloc((length+1) * sizeof(char)))) return -1; memcpy(seq2, seq1, length); tim = time(NULL); seed = (int) tim; scramble_seq(seq2, length, seed); seq2[length] = '\0'; parental_name = GetParentalSeqName(seq_num); child_name = GetSeqName(seq_num); if (NULL == (name = (char *)xmalloc((strlen(parental_name)+13) * sizeof(char)))) return -1; sprintf(name, "%s_x%d", parental_name, num); if (-1 == (new_seq_num = AddSequence(interp, -1, GetSeqLibrary(seq_num), name, seq2, GetSeqStructure(seq_num), GetSeqType(seq_num), NULL , " "))) return -1; xfree(name); if (strcmp(parental_name, child_name) != 0) { /* sub-sequence */ /* * need to get seq num from seq_id instead of using seq_num incase * AddSequence has deleted duplicate names */ start = GetSubSeqStart(GetSeqNum(seq_id)); end = GetSubSeqEnd(GetSeqNum(seq_id)); if (NULL == (name = (char *)xmalloc((strlen(child_name)+13) * sizeof(char)))) return -1; sprintf(name, "%s_x%d", child_name, num); if (-1 == (AddSubSequence(interp, GetSeqId(new_seq_num), start, end, name))) return -1; } num++; return 0; }
/* * complement sequence * add new sequence name to sequence manager */ int ComplementSeq(Tcl_Interp *interp, int seq_num) { char *seq1 = GetSeqSequence(seq_num); char *seq2; char *name; int length = GetSeqLength(seq_num); int seq_id = GetSeqId(seq_num); int new_seq_num, start, end; char *parental_name, *child_name; if (NULL == (seq2 = (char *)xmalloc((length+1) * sizeof(char)))) return -1; memcpy(seq2, seq1, length); (void) complement_seq(seq2, length); seq2[length] = '\0'; parental_name = GetParentalSeqName(seq_num); child_name = GetSeqName(seq_num); if (NULL == (name = (char *)xmalloc((strlen(parental_name)+3) * sizeof(char)))) return -1; sprintf(name, "%s_c", parental_name); if (-1 == (new_seq_num = AddSequence(interp, -1, GetSeqLibrary(seq_num), name, seq2, GetSeqStructure(seq_num), GetSeqType(seq_num), NULL, " "))) return -1; xfree(name); if (strcmp(parental_name, child_name) != 0) { /* sub-sequence */ /* * need to get seq num from seq_id instead of using seq_num incase * AddSequence has deleted duplicate names */ start = GetSubSeqStart(GetSeqNum(seq_id)); end = GetSubSeqEnd(GetSeqNum(seq_id)); if (NULL == (name = (char *)xmalloc((strlen(child_name)+3) * sizeof(char)))) return -1; sprintf(name, "%s_c", child_name); if (-1 == (AddSubSequence(interp, GetSeqId(new_seq_num), length - end + 1, length - start + 1, name))) return -1; } return 0; }
/* * add new sequence to sequence manager, but keep as dna but with an extension * of _rf123 which signifies to the comparison functions that the sequence * is to translated into it's 3 reading frames, each of which will be used * in the comparison routine */ int TranslateTogether(Tcl_Interp *interp, int seq_num) { char *name; char *dna_seq; char *prot_seq; int seq_id = GetSeqId(seq_num); int new_seq_num; char *parental_name, *child_name; int start, end; #ifdef DEBUG printf("START translate together \n"); #endif dna_seq = GetSeqSequence(seq_num); if (NULL == (prot_seq = strdup(dna_seq))) return -1; parental_name = GetParentalSeqName(seq_num); child_name = GetSeqName(seq_num); if (NULL == (name = (char *)xmalloc((strlen(parental_name)+7) * sizeof(char)))) return -1; sprintf(name, "%s_rf123", parental_name); if (-1 == (new_seq_num = AddSequence(interp, -1, GetSeqLibrary(seq_num), name, prot_seq, LINEAR, PROTEIN, NULL, " "))) return -1; xfree(name); if (strcmp(parental_name, child_name) != 0) { /* sub-sequence */ /* * need to get seq num from seq_id instead of using seq_num incase * AddSequence has deleted duplicate names */ start = GetSubSeqStart(GetSeqNum(seq_id)); end = GetSubSeqEnd(GetSeqNum(seq_id)); if (NULL == (name = (char *)xmalloc((strlen(child_name)+7) * sizeof(char)))) return -1; sprintf(name, "%s_rf123", child_name); new_seq_num = AddSubSequence(interp, GetSeqId(new_seq_num), start, end, name); } return new_seq_num; }
int store_sim2(int seq1_num, int seq2_num, int start_h, int end_h, int start_v, int end_v, in_sim *input, d_plot *data, int n_pts) { seq_result *result; int id; if (NULL == (result = (seq_result *)xmalloc(sizeof(seq_result)))) return -1; /* realloc p_array to be the actual number of lines */ if (NULL == (data->p_array = (pt_score *)realloc(data->p_array, (n_pts+1)* sizeof(pt_score)))) return -1; id = get_reg_id(); result->data = data; data->n_pts = n_pts; data->dim.x0 = start_h; data->dim.x1 = end_h; data->dim.y0 = start_v; data->dim.y1 = end_v; /* need to initialise this here */ result->output = NULL; result->seq_id[HORIZONTAL] = GetSeqId( seq1_num); result->seq_id[VERTICAL] = GetSeqId(seq2_num); result->input = (void *)input; result->id = id; result->graph = SEQ_DOT; result->pr_func = dot_plot_line_func; result->op_func = sim_callback; result->txt_func = sim_text_func; seq_register(seq1_num, sim_callback, (void *)result, SEQ_PLOT_PERM, id); seq_register(seq2_num, sim_callback, (void *)result, SEQ_PLOT_PERM, id); return id; }
string CurrentLocationAsString () const { return GetSeqId() + " | " + NStr::IntToString(GetVersion()) + " | " + NStr::UInt8ToString(GetGi()) + " | " + NStr::IntToString(GetTimestamp()); }
/* * add sequence to seqed widget */ int add_seq_seqed(Tcl_Interp *interp, char *sequence, char *seqed_win, int seq_num, int pos, int container_id, char *c_win, int element_id) { Tcl_CmdInfo info; tkSeqed *se; char *seq_name; int sequence_type; int seqed_id; Tcl_GetCommandInfo(interp, seqed_win, &info); se = (tkSeqed*)info.clientData; seq_name = GetSeqName(seq_num); sequence_type = GetSeqStructure(seq_num); seqed_add_sequence(se, strlen(sequence), sequence, seq_name, sequence_type, GetSeqId(seq_num), 0, 0); seqed_id = seqed_reg(interp, seqed_win, seq_num, se, pos, container_id, c_win, element_id); return seqed_id; }
int seqed_reg(Tcl_Interp *interp, char *seqed_win, int seq_num, tkSeqed *se) { int id; SeqedResult *seqed_result; char *colour; seq_cursor_notify cn; int line_width; if (NULL == (seqed_result = (SeqedResult *)xmalloc(sizeof(SeqedResult)))) return -1; seqed_result->op_func = seqed_callback; seqed_result->seq_id = GetSeqId(seq_num); strcpy(seqed_result->seqed_win, seqed_win); seqed_result->interp = interp; id = get_reg_id(); seqed_result->index = id; line_width = get_default_int(interp, spin_defs, w("SEQ.CURSOR.LINE_WIDTH")); colour = get_raster_colour(); se->rid = id; se->seq_id = GetSeqId(seq_num); strcpy(se->cursorCol, colour); se->cursor = create_cursor(seq_num, 1, NULL, line_width, 1, HORIZONTAL); se->cursor_visible = 0; se->prev_pos = se->cursor->abspos; se->cursor->abspos = se->cursorPos; seq_register(seq_num, seqed_callback, (void *)seqed_result, SEQ_SEQED, id); cn.job = SEQ_CURSOR_NOTIFY; cn.cursor = se->cursor; cn.cursor->job = CURSOR_MOVE; seq_notify(seq_num, (seq_reg_data *)&cn); return id; }
ostream& Print( ostream& o ) const { return o << GetSeqId() << "\t" << GetPos() << "\t" << GetProb(0) << "\t" << GetProb(1) << "\t" << GetProb(2) << "\t" << GetProb(3); }
/* * copy range of sequence * add new sequence name to sequence manager */ int CopyRange(Tcl_Interp *interp, int seq_id, int start, int end) { int seq_num = GetSeqNum(seq_id); char *seq1 = GetSeqSequence(seq_num); char *seq2; char *name; int length = end - start + 1; int new_seq_num; char *parental_name, *child_name; static int count = 1; if (NULL == (seq2 = (char *)xmalloc((length+2) * sizeof(char)))) return -1; strncpy(seq2, &seq1[start-1], end - start + 1); seq2[end - start + 1] = '\0'; parental_name = GetParentalSeqName(seq_num); child_name = GetSeqName(seq_num); if (NULL == (name = (char *)xmalloc((strlen(parental_name)+20) * sizeof(char)))) return -1; sprintf(name, "%s_n%d", parental_name, count++); if (-1 == (new_seq_num = AddSequence(interp, -1, GetSeqLibrary(seq_num), name, seq2, GetSeqStructure(seq_num), GetSeqType(seq_num), NULL, " "))) return -1; xfree(name); /* don't think I need to deal with subsequences in copying a sequence. */ #if 0 if (strcmp(parental_name, child_name) != 0) { /* sub-sequence */ /* * need to get seq num from seq_id instead of using seq_num incase * AddSequence has deleted duplicate names */ start = GetSubSeqStart(GetSeqNum(seq_id)); end = GetSubSeqEnd(GetSeqNum(seq_id)); if (NULL == (name = (char *)xmalloc((strlen(child_name)+3) * sizeof(char)))) return -1; sprintf(name, "%s_n%d", child_name, count++); if (-1 == (AddSubSequence(interp, GetSeqId(new_seq_num), start, end, name))) return -1; } #endif return 0; }
int store_emboss_dot(int seq_num_h, int start_h, int end_h, int seq_num_v, int start_v, int end_v, e_graph *data, in_emboss *input, text_emboss *text_data, Tcl_Obj **graph_obj) { seq_result *s_result; int id; if (NULL == (s_result = (seq_result *)xmalloc(sizeof(seq_result)))) return -1; id = get_reg_id(); /* data assignment */ s_result->seq_id[HORIZONTAL] = GetSeqId(seq_num_h); s_result->seq_id[VERTICAL] = GetSeqId(seq_num_v); s_result->id = id; s_result->input = (void *)input; s_result->type = SEQ_TYPE_DOT_PLOT; s_result->gr_type = SEQ_TYPE_DOT_PLOT; s_result->frame = 0; s_result->graph = GRAPH; s_result->data = *graph_obj; s_result->text_data = text_data; s_result->e = NULL; s_result->pr_func = seq_plot_graph_func; s_result->op_func = emboss_graph_callback; s_result->txt_func = emboss_graph_text_func; seq_register(seq_num_h, emboss_graph_callback, (void *)s_result, SEQ_PLOT_PERM, id); seq_register(seq_num_v, emboss_graph_callback, (void *)s_result, SEQ_PLOT_PERM, id); return id; }
Seq &SeqVect::GetSeqById(unsigned uId) { const unsigned uSeqCount = GetSeqCount(); for (unsigned i = 0; i < uSeqCount; ++i) { if (GetSeqId(i) == uId) return GetSeq(i); } Quit("SeqVect::GetSeqIdByUd(%d): not found", uId); return (Seq &) *((Seq *) 0); }
unsigned SeqVect::GetSeqIdFromName(const char *Name) const { const unsigned uSeqCount = GetSeqCount(); for (unsigned i = 0; i < uSeqCount; ++i) { if (!strcmp(Name, GetSeqName(i))) return GetSeqId(i); } Quit("SeqVect::GetSeqIdFromName(%s): not found", Name); return 0; }
const CBioseq_Handle& CAlnVec::GetBioseqHandle(TNumrow row) const { TBioseqHandleCache::iterator i = m_BioseqHandlesCache.find(row); if (i != m_BioseqHandlesCache.end()) { return i->second; } else { CBioseq_Handle bioseq_handle = GetScope().GetBioseqHandle(GetSeqId(row)); if (bioseq_handle) { return m_BioseqHandlesCache[row] = bioseq_handle; } else { string errstr = string("CAlnVec::GetBioseqHandle(): ") + "Seq-id cannot be resolved: " + GetSeqId(row).AsFastaString(); NCBI_THROW(CAlnException, eInvalidSeqId, errstr); } } }
int CSeq_id_Handle::CompareOrdered(const CSeq_id_Handle& id) const { // small optimization to avoid creation of temporary CSeq_id objects if ( int diff = Which() - id.Which() ) { return diff; } if ( IsGi() && id.IsGi() ) { return GetGi() - id.GetGi(); } return GetSeqId()->CompareOrdered(*id.GetSeqId()); }
string CSeq_id_Handle::AsString() const { CNcbiOstrstream os; if ( IsGi() ) { os << "gi|" << m_Packed; } else if ( m_Info ) { GetSeqId()->WriteAsFasta(os); } else { os << "unknown"; } return CNcbiOstrstreamToString(os); }
int store_emboss_graph(int seq_num, int start, int end, e_graph *data, in_emboss *input, text_emboss *text_data, Tcl_Obj **graph_obj) { seq_result *s_result; int id; #ifdef DEBUG for (i = 0; i < data->n_pts; i++) { printf("i %d pos %d score %f\n", i, data->p_array[i].pos, data->p_array[i].score); } #endif if (NULL == (s_result = (seq_result *)xmalloc(sizeof(seq_result)))) return -1; id = get_reg_id(); s_result->seq_id[HORIZONTAL] = GetSeqId(seq_num); s_result->seq_id[VERTICAL] = -1; s_result->id = id; s_result->input = (void *)input; s_result->type = SEQ_TYPE_GRAPH_PLOT; s_result->gr_type = SEQ_TYPE_GRAPH_PLOT; s_result->frame = 0; s_result->graph = GRAPH; s_result->data = *graph_obj; s_result->text_data = text_data; s_result->e = NULL; s_result->pr_func = seq_plot_graph_func; s_result->op_func = emboss_graph_callback; s_result->txt_func = emboss_graph_text_func; seq_register(seq_num, emboss_graph_callback, (void *)s_result, SEQ_PLOT_PERM, id); return id; }
int TranslateSeq(Tcl_Interp *interp, int seq_num, int rf, int start, int end) { int i; char *name; char *dna_seq; char *prot_seq; int cnt = 0; int seq_id = GetSeqId(seq_num); int new_seq_num; char *ptr; char *parental_name, *child_name; char *new_name; int length = end - start + 1; static int num = 0; #ifdef DEBUG printf("START translate seq %d to %d\n", start, end); #endif dna_seq = GetSeqSequence(seq_num); if (NULL == (prot_seq = (char *)xmalloc(((length/3)+3) * sizeof(char)))) return -1; if (NULL == (new_name = (char *)xmalloc(strlen(GetSeqName(seq_num)) * sizeof(char)))) return -1; for (i = rf+start-1; i < end-2; i+=3) { prot_seq[cnt++] = codon_to_acid1(&dna_seq[i]); } prot_seq[cnt] = '\0'; #ifdef DEBUG printf("%s\n", prot_seq); #endif /* * special case: remove _rf123 from name before adding _rfx to end */ parental_name = GetParentalSeqName(seq_num); child_name = GetSeqName(seq_num); ptr = strstr(parental_name, "_rf123"); if (NULL == (name = (char *)xmalloc((strlen(parental_name)+28) * sizeof(char)))) return -1; if (ptr) { strncpy(new_name, parental_name, (ptr - parental_name)); new_name[ptr - parental_name] = '\0'; strcat(new_name, ptr+6); sprintf(name, "%s_rf%d_%d", new_name, rf+1, num); } else { sprintf(name, "%s_rf%d_%d", parental_name, rf+1, num); } /* proteins can only be LINEAR ! */ if (-1 == (new_seq_num = AddSequence(interp, -1, GetSeqLibrary(seq_num), name, prot_seq, LINEAR, PROTEIN, NULL, " "))) return -1; xfree(name); xfree(new_name); if (strcmp(parental_name, child_name) != 0) { /* sub-sequence */ /* * need to get seq num from seq_id instead of using seq_num incase * AddSequence has deleted duplicate names */ start = ceil((GetSubSeqStart(GetSeqNum(seq_id))-1)/3.0 + 1); end = (GetSubSeqEnd(GetSeqNum(seq_id)) - rf) / 3; if (NULL == (name = (char *)xmalloc((strlen(child_name)+15) * sizeof(char)))) return -1; if (NULL == (new_name = (char *)xmalloc(strlen(GetSeqName(seq_num)) * sizeof(char)))) return -1; ptr = strstr(child_name, "_rf123"); if (ptr) { strncpy(new_name, child_name, (ptr - child_name)); new_name[ptr - child_name] = '\0'; strcat(new_name, ptr+6); sprintf(name, "%s_rf%d_%d", new_name, rf+1, num); } else { sprintf(name, "%s_rf%d_%d", child_name, rf+1, num); } /* sprintf(name, "%s_rf%d", child_name, rf+1); */ new_seq_num = AddSubSequence(interp, GetSeqId(new_seq_num), start, end, name); xfree(new_name); } num++; return new_seq_num; }
int store_string_search(int seq_num, in_string_search *input, int start, int end, int *pos, int *score, int n_matches, int string_length) { seq_result *result; int id; int i; stick *data; if (NULL == (result = (seq_result *)xmalloc(sizeof(seq_result)))) return -1; if (NULL == (data = (stick *)xmalloc(sizeof(stick)))) return -1; if (NULL == (data->ap_array = (a_score *)xmalloc(sizeof(a_score)))) return -1; if (NULL == (data->ap_array[0].p_array = (p_score *)xmalloc(n_matches * sizeof(p_score)))) return -1; result->data = data; data->n_pts = 1; data->ap_array[0].n_pts = n_matches; data->ap_array[0].dim.x0 = start; data->ap_array[0].dim.x1 = end; data->ap_array[0].dim.y0 = 0; data->ap_array[0].dim.y1 = 100; for (i = 0; i < n_matches; i++) { data->ap_array[0].p_array[i].pos = pos[i] + start - 1; data->ap_array[0].p_array[i].score = (double)score[i] / string_length * 100; } id = get_reg_id(); result->seq_id[HORIZONTAL] = GetSeqId(seq_num); result->seq_id[VERTICAL] = -1; result->id = id; result->input = (void *)input; result->output = NULL; result->type = SEQ_TYPE_STRINGSEARCH; result->frame = 0; result->graph = SEQ_STICK; result->pr_func = stick_plot_func; result->op_func = nip_string_search_callback; result->txt_func = nip_string_search_text_func; seq_register(seq_num, nip_string_search_callback, (void *)result, SEQ_PLOT_PERM, id); return id; }
int store_stop_codons(int seq_num, in_s_codon *input, int start, int end, int *stop_codon, int num_stop_codons, int frame, int type, Tcl_Obj **graph_obj) { seq_result *s_result; Graph *graph; int id, i; if (NULL == (s_result = (seq_result *)xmalloc(sizeof(seq_result)))) return -1; if (NULL == (graph = (Graph *)xmalloc(sizeof(Graph)))) return -1; Tcl_InitGraph(&graph); if (NULL == (graph->d_arrays = (darray *)xmalloc(sizeof(darray)))) return -1; if (NULL == (graph->d_arrays[0].d_array = (gd_line *)xmalloc(num_stop_codons * sizeof(gd_line)))) return -1; graph->d_arrays[0].n_dlines = num_stop_codons; graph->n_darrays = 1; graph->d_arrays[0].type = G_LINES; graph->dim.x0 = start; graph->dim.x1 = end; for (i = 0; i < num_stop_codons; i++) { graph->d_arrays[0].d_array[i].x0 = stop_codon[i]; graph->d_arrays[0].d_array[i].x1 = stop_codon[i]; } /* must sort the array on x0 */ qsort((void *) graph->d_arrays[0].d_array, graph->d_arrays[0].n_dlines, sizeof(gd_line), compare_darray); *graph_obj = Tcl_NewGraphObj(graph); /* these are copied over in Tcl_NewGraphObj so don't need them anymore */ xfree(graph->d_arrays[0].d_array); xfree(graph->d_arrays); xfree(graph); id = get_reg_id(); s_result->seq_id[HORIZONTAL] = GetSeqId(seq_num); s_result->seq_id[VERTICAL] = -1; s_result->id = id; s_result->input = (void *)input; s_result->frame = frame; s_result->graph = GRAPH; s_result->data = *graph_obj; s_result->e = NULL; /* initialise */ s_result->pr_func = seq_plot_graph_func; s_result->op_func = nip_stop_codons_callback; s_result->txt_func = nip_stop_codons_text_func; if (type == STOP_CODON) { s_result->type = SEQ_TYPE_STOPCODON; } else { s_result->type = SEQ_TYPE_STARTCODON; } s_result->gr_type = SEQ_TYPE_GRAPH_PLOT; seq_register(seq_num, nip_stop_codons_callback, (void *)s_result, SEQ_PLOT_PERM, id); xfree(stop_codon); return id; }
int StoreSpliceSearch(int seq_num, WtmatrixRes *ied, WtmatrixRes *eia, in_splice *input, int start, int end, int frame) { seq_result *result; stick *data; int id, i; text_wtmatrix **text_data; if (NULL == (result = (seq_result *)xmalloc(sizeof(seq_result)))) return -1; if (NULL == (data = (stick *)xmalloc(sizeof(stick)))) return -1; if (NULL == (data->ap_array = (a_score *)xmalloc(2 * sizeof(a_score)))) return -1; if (NULL == (data->ap_array[0].p_array = (p_score *)xmalloc(ied->number_of_res * sizeof(p_score)))) return -1; if (NULL == (data->ap_array[1].p_array = (p_score *)xmalloc(eia->number_of_res * sizeof(p_score)))) return -1; if (NULL == (text_data = (text_wtmatrix **)xmalloc(2*sizeof(text_wtmatrix*)))) return -1; if (NULL == (text_data[0] = (text_wtmatrix *)xmalloc(sizeof(text_wtmatrix)))) return -1; if (NULL == (text_data[1] = (text_wtmatrix *)xmalloc(sizeof(text_wtmatrix)))) return -1; result->data = data; data->n_pts = 2; data->ap_array[0].n_pts = ied->number_of_res; data->ap_array[1].n_pts = eia->number_of_res; data->ap_array[0].dim.x0 = start; data->ap_array[0].dim.x1 = end; data->ap_array[0].dim.y0 = ied->min; data->ap_array[0].dim.y1 = 2*ied->max; data->ap_array[1].dim.x0 = start; data->ap_array[1].dim.x1 = end; data->ap_array[1].dim.y0 = eia->min; data->ap_array[1].dim.y1 = 2*eia->max; #ifdef DEBUG printf("ied %f %f eia %f %f\n", ied->min, ied->max, eia->min, eia->max); #endif id = get_reg_id(); for (i = 0; i < ied->number_of_res; i++) { data->ap_array[0].p_array[i].pos = ied->match[i]->pos + 1; data->ap_array[0].p_array[i].score = (double)ied->match[i]->score; } for (i = 0; i < eia->number_of_res; i++) { data->ap_array[1].p_array[i].pos = eia->match[i]->pos + 1; data->ap_array[1].p_array[i].score = (double)eia->match[i]->score; } result->text_data = text_data; text_data[0]->length = ied->length; text_data[0]->mark_pos = ied->mark_pos; text_data[1]->length = eia->length; text_data[1]->mark_pos = eia->mark_pos; result->seq_id[HORIZONTAL] = GetSeqId(seq_num); result->seq_id[VERTICAL] = -1; result->id = id; result->input = (void *)input; result->output = NULL; result->type = SEQ_TYPE_SPLICE; result->frame = frame; result->graph = SEQ_STICK; result->pr_func = stick_pair_plot_func; result->op_func = splice_search_callback; result->txt_func = splice_search_text_func; seq_register(seq_num, splice_search_callback, (void *)result, SEQ_PLOT_PERM, id); if (ied) free_WtmatrixRes (ied); if (eia) free_WtmatrixRes (eia); return id; }
int store_sip_similar_spans(int seq1_num, int seq2_num, int window_length, int min_score, int start_h, int end_h, int start_v, int end_v, int *seq1_match, int *seq2_match, int *match_score, int num_elements, in_comp_spans *input) { seq_result *sip_result; d_plot *data; text_sim_spans *text_data; int i, id; if (NULL == (sip_result = (seq_result *)xmalloc(sizeof(seq_result)))) return -1; if (NULL == (data = (d_plot *)xmalloc(sizeof(d_plot)))) return -1; if (NULL == (data->p_array = (pt_score *)xmalloc(sizeof(pt_score) * num_elements))) return -1; if (NULL == (text_data = (text_sim_spans *)xmalloc(sizeof(text_sim_spans)))) return -1; id = get_reg_id(); sip_result->data = data; /* data assignment */ for (i = 0; i < num_elements; i++) { data->p_array[i].x = seq1_match[i]; data->p_array[i].y = seq2_match[i]; data->p_array[i].score = match_score[i]; } data->win_len = window_length; data->n_pts = num_elements; data->dim.x0 = start_h; data->dim.x1 = end_h; data->dim.y0 = start_v; data->dim.y1 = end_v; sip_result->text_data = text_data; text_data->min_score = min_score; /* need to initialise this here */ sip_result->output = NULL; /* save global sip_seq into sip_result structure */ sip_result->seq_id[HORIZONTAL] = GetSeqId(seq1_num); sip_result->seq_id[VERTICAL] = GetSeqId(seq2_num); sip_result->input = (void *)input; sip_result->id = id; sip_result->graph = SEQ_DOT; sip_result->pr_func = dot_plot_middot_func; sip_result->op_func = similar_spans_callback; sip_result->txt_func = similar_spans_text_func; seq_register(seq1_num, similar_spans_callback, (void *)sip_result, SEQ_PLOT_PERM, id); seq_register(seq2_num, similar_spans_callback, (void *)sip_result, SEQ_PLOT_PERM, id); return id; }
int seqed_reg(Tcl_Interp *interp, char *seqed_win, int seq_num, tkSeqed *se, int pos, int container_id, char *c_win, int element_id) { int id; SeqedResult *seqed_result; char *colour; seq_cursor_notify cn; int line_width; element *e; plot_data *result; if (NULL == (seqed_result = (SeqedResult *)xmalloc(sizeof(SeqedResult)))) return -1; if (NULL == (result = (plot_data *)xmalloc(sizeof(plot_data)))) return -1; seqed_result->op_func = seqed_callback; seqed_result->seq_id = GetSeqId(seq_num); strcpy(seqed_result->seqed_win, seqed_win); seqed_result->interp = interp; id = get_reg_id(); seqed_result->index = id; line_width = get_default_int(interp, spin_defs, w("SEQ.CURSOR.LINE_WIDTH")); se->rid = id; se->seq_id = GetSeqId(seq_num); colour = get_cursor_colour(se->rid); strcpy(se->cursorCol, colour); se->cursor = create_cursor(seq_num, 1, NULL, line_width, 1, HORIZONTAL, pos); se->cursor_visible = 0; se->prev_pos = se->cursor->abspos; se->cursor->abspos = se->cursorPos; if (NULL == (e = (get_element(element_id)))) { e = create_element(interp, container_id, element_id, seqed_win, HORIZONTAL, -1); } seqed_result->e = e; result->result_id = id; result->amp_ruler = 0; result->len_ruler = 0; result->n_configure = 0; result->sf_m = 1.0; result->sf_c = 0.0; result->scale = 0; result->hidden = 0; result->colour = NULL; result->cursor = NULL; set_seq_element_funcs(e); add_seq_id_to_element(e, GetSeqId(seq_num), HORIZONTAL); add_result_to_element(e, result, DBL_MAX, DBL_MAX, -DBL_MAX, -DBL_MAX, HORIZONTAL, SEQ_EDITOR); add_element_to_container(interp, container_id, c_win, e, INT_MAX, INT_MIN, INT_MAX, INT_MIN); seq_register(seq_num, seqed_callback, (void *)seqed_result, SEQ_SEQED, id); seq_element_reg(interp, e); cn.job = SEQ_CURSOR_NOTIFY; cn.cursor = se->cursor; cn.cursor->job = CURSOR_MOVE; cn.show_all = 0; seq_notify(seq_num, (seq_reg_data *)&cn); return id; }