Sequence * realloc_sequence (Sequence *OUT, int new_nseq, int max_len) { if ( new_nseq<OUT->max_nseq) return OUT; OUT->min_len =MIN(OUT->min_len,max_len); OUT->max_len =MAX(OUT->max_len,max_len); OUT->seq_comment =new_realloc_char ( OUT->seq_comment, new_nseq,COMMENT_SIZE); OUT->aln_comment =new_realloc_char ( OUT->aln_comment, new_nseq,COMMENT_SIZE); OUT->seq =new_realloc_char ( OUT->seq, new_nseq,OUT->max_len+1); OUT->name =new_realloc_char ( OUT->name, new_nseq,MAXNAMES+1); if (OUT->genome_co != NULL) OUT->genome_co = vrealloc(OUT->genome_co, new_nseq * sizeof(Genomic_info)); OUT->file =new_realloc_char ( OUT->file, new_nseq,STRING+1); OUT->len =vrealloc ( OUT->len, (new_nseq+1)*sizeof (int)); OUT->T=(Template**)realloc_arrayN (2, (void **)OUT->T,sizeof (Template), new_nseq, 1); OUT->dc=(int **)realloc_arrayN (2, (void **)OUT->dc,sizeof (int), new_nseq, 2); OUT->max_nseq=new_nseq; return OUT; }
Alignment * realloc_alignment2 ( Alignment *A, int n_nseq, int n_len) { int a; int len, nseq; int delta_len, delta_nseq; if ( A==NULL) A=declare_Alignment(NULL); n_len++; n_nseq++; len=A->declared_len; nseq=A->max_n_seq; n_len=MAX(len, n_len); n_nseq=MAX(nseq,n_nseq); delta_nseq=MAX(0,n_nseq-nseq); delta_len =MAX(0,n_len-len); if ( delta_nseq<=0 && delta_len<=0)return A; else { A->len =vrealloc( A->len , sizeof (int)*n_nseq); for (a=nseq; a< n_nseq; a++)A->len[a]=0; A->declared_len =n_len; A->max_n_seq =n_nseq; A->seq_comment=new_realloc_char ( A->seq_comment, n_nseq, -1); A->aln_comment=new_realloc_char ( A->aln_comment, n_nseq, -1); A->name =new_realloc_char ( A->name, n_nseq, -1); A->file =new_realloc_char ( A->file, n_nseq, -1); A->tree_order =new_realloc_char ( A->tree_order, n_nseq, -1); A->seq_al =new_realloc_char ( A->seq_al, n_nseq, n_len); A->order =new_realloc_int ( A->order, n_nseq, -1); if ( A->seq_cache) A->seq_cache=new_realloc_int ( A->seq_cache, n_nseq,n_len); if ( A->cdna_cache)A->cdna_cache=new_realloc_int ( A->cdna_cache, n_nseq,n_len); A->score_seq =vrealloc( A->score_seq, sizeof (int)*(n_nseq)); for ( a=nseq; a< n_nseq; a++)A->score_seq[a]=0; } return A; }
SeqHasch * seq2hasch (int i,char *seq, int ktup, SeqHasch *H) { int a,b,l, n=0; SeqHasch h; if (!H) { H=(hseq**)vcalloc (2, sizeof (SeqHasch)); H[0]=(hseq*)vcalloc (1, sizeof (hseq)); n=1; } else { n=0; while (H[++n]); } l=strlen (seq); for (a=0; a<l-ktup; a++) { h=H[0]; for (b=a; b<a+ktup; b++) { char r; r=seq[b]; if (!h->hl[r]) h->hl[r]=(hseq*)vcalloc (1, sizeof (hseq)); h=h->hl[r]; } if (!h->l) { h->n=2; h->l=(int*)vcalloc (2, sizeof (int)); H=(hseq**)vrealloc (H,(n+2)*sizeof (SeqHasch)); H[n]=h; n++; } else { h->n+=2; h->l=(int*)vrealloc (h->l, (h->n)*sizeof (int)); } h->l[h->n-2]=i; h->l[h->n-1]=a; } return H; }
struct Hasch_data * allocate_ktup_hasch_data (struct Hasch_data *e, int action) { static struct Hasch_data **heap; static int heap_size, free_heap, a; if ( action == 100) { fprintf ( stderr, "\nHeap size: %d, Free Heap: %d", heap_size, free_heap); return NULL; } else if ( action==DECLARE) { if ( free_heap==0) { free_heap=100; heap_size+=free_heap; heap=(Hasch_data**)vrealloc (heap,heap_size*sizeof (struct Hasch_entry *)); for ( a=0; a<free_heap; a++) { (heap[a])=(Hasch_data*)vcalloc ( 1, sizeof ( struct Hasch_entry *)); (heap[a])->list=(int*)vcalloc ( 10, sizeof (int)); (heap[a])->list[0]=10; } } return heap[--free_heap]; } else if ( action==FREE) { heap[free_heap++]=e; e->list[1]=0; return NULL; } return NULL; }
Char_node * declare_char_node (int action) { static struct Char_node **heap; static int heap_size, free_heap, a; static int key; if ( action==DECLARE) { if ( free_heap==0) { free_heap=100; heap=vrealloc (heap,(heap_size+free_heap)*sizeof (struct Char_node *)); for ( a=heap_size; a<heap_size+free_heap; a++) { (heap[a])=vcalloc ( 1, sizeof ( struct Char_node)); (heap[a])->c=vcalloc ( 256, sizeof (Char_node*)); (heap[a])->key=key++; } heap_size+=free_heap; } return heap[heap_size-(free_heap--)]; } else if ( action==FREE_STACK) { for (a=0; a< heap_size; a++) { heap[a]->key=key++; vfree ( heap[a]->c); (heap[a])->c=vcalloc ( 256, sizeof (Char_node*)); } free_heap=heap_size; return NULL; } return NULL; }
int seq_pair2blast_diagonal2(char *seq_file_name1, char *seq_file_name2, Diagonal **diagonals, int *dig_length, int l1, int l2, int is_dna) { char *out_file = vtmpnam(NULL); char blast_command[200]; char blast_command2[200]; if (is_dna) { sprintf(blast_command, "bl2seq -p blastn -i %s -j %s -D 1 -g F -o %s -S 1 -F F", seq_file_name1, seq_file_name2, out_file); } else { sprintf(blast_command, "bl2seq -p blastp -i %s -j %s -D 1 -g F -o %s -F F -S 1", seq_file_name1, seq_file_name2, out_file); } system(blast_command); Diagonal *diags = diagonals[0]; FILE *diag_f = fopen(out_file,"r"); char line[300]; fgets(line, 300, diag_f); fgets(line, 300, diag_f); fgets(line, 300, diag_f); char delims[] = "\t"; int length, pos_q, pos_d; int current_pos = 0; while (fgets(line, 300, diag_f) != NULL) { strtok(line, delims); strtok(NULL, delims); strtok(NULL, delims); length = atoi(strtok(NULL, delims)); strtok(NULL, delims); strtok(NULL, delims); pos_q = atoi(strtok(NULL, delims)); strtok(NULL, delims); pos_d = atoi(strtok(NULL, delims)); if (current_pos >= *dig_length) { (*dig_length) += 40; diags = (Diagonal*)vrealloc(diags, sizeof(Diagonal)*(*dig_length)); } diags[current_pos].x = pos_q; diags[current_pos].y = pos_d; diags[current_pos++].length = length; } fclose(diag_f); diagonals[0] = diags; return current_pos; }
/** * Deletes all gap columns from the profile. * * \param prf The profile. * \param alphabet_size The size of the alphabet. * \param gap_list The gap_list. * \param gap_list_length The length of the gap list. * \param num_gaps The number of gaps. * \return The new gap list. */ int * del_gap_from_profile(Fastal_profile *prf, int alphabet_size, int *gap_list, int *gap_list_length, int *num_gaps) { int i; int pos = -1; int not_gap = 0; int gap_pos = 0; int write_pos = 0; // int gap_counter = 0; int **prf_in = prf->prf; int prf_length = prf->length; while (gap_pos < prf_length) { // printf("PRF1: %i %i %i %i\n", prf_in[0][gap_pos], prf_in[1][gap_pos], prf_in[2][gap_pos], prf_in[3][gap_pos]); not_gap = 0; for (i = 0; i < alphabet_size; ++i) { if (prf_in[i][gap_pos]) { not_gap = 1; // printf("ARG: %i\n", i); break; } } if (not_gap) { if (gap_pos != write_pos) { for (i = 0; i < alphabet_size; ++i) { prf_in[i][write_pos] = prf_in[i][gap_pos]; } } ++write_pos; } else { if (++pos >= *gap_list_length) { *gap_list_length += 10; gap_list = (int*)vrealloc(gap_list, (*gap_list_length)*sizeof(int)); } gap_list[pos] = gap_pos; // ++gap_counter; } ++gap_pos; } // printf("DEEEEEEEEEEEEEEEEEL %i %i\n", gap_counter, pos+1); *num_gaps = pos+1; prf->length -= *num_gaps; return gap_list; }
void *ckvrealloc(void *ptr, size_t bytes){ register void *ret; extern void *vrealloc (void *ptr, size_t size); if( (ret = vrealloc(ptr, bytes)) == NULL){ fprintf(stderr, "ERROR - Out of memory\n"); } else{ return ret; } return ret; }
Structure *extend_structure ( Structure *S) { int a, b; for ( a=0; a< S->nseq; a++) { for ( b=0; b< S->len[a]; b++) S->struc[a][b]=vrealloc ( S->struc[a][b],( S->n_fields+1)*sizeof (int)); } S->n_fields++; return S; }
Fastal_profile * enlarge_prof(Fastal_profile *prof, int new_length, int alphabet_size) { if (new_length > prof->allocated_memory) { int i; for (i = 0; i < alphabet_size; ++i) { prof->prf[i] = (int*)vrealloc(prof->prf[i],new_length*sizeof(int)); } prof->allocated_memory = new_length; } return prof; }
long aln_stack (Alignment *A, int mode) { static long *list; static int size; static int max_size; if (A==NULL) return 0; else if ( mode==DECLARE_ALN) { if ( size==max_size) { max_size+=1000; list=vrealloc (list, max_size*sizeof (long)); } list[size++]=(long)A; return 0; } else if (mode==FREE_ALN) { int a, b; for (a=0; a<size; a++) { if (list[a]==(long)A) { for (b=a+1; b<size;b++) { list[b-1]=list[b]; } list[b-1]=0; size--; return 1; } } return 0; } else if ( mode==EXTRACT_ALN) { return list[size--]; } else { printf_exit (EXIT_FAILURE, stderr, "ERROR: Unknown mode for aln_stack"); return 0; } }
/**************HASHING UTILITIES**************************/ Bin_node * find_val_in_bin_tree ( Bin_node ** Node_list,Bin_node *N,int index, int *bin_val, int n, int len, int *used) { Bin_node *C; if (used[0]==0){used[0]=1;N=Node_list[0];N->left_child=NULL; N->right_child=NULL;N->index=0;} if ( n==len) { N->n++; if (N->n==0)N->n++; if (N->n>N->max_list) { N->list=vrealloc ( N->list, N->n*sizeof (int)); N->max_list=N->n; } N->list[N->n-1]=index; return N; } else { if ( N->left_child && !bin_val[n]){C=N->left_child ;} else if ( N->right_child && bin_val[n]){C=N->right_child;} else { if ( !bin_val[n]){C=N->left_child =Node_list[used[0]++];} else if (bin_val[n]){C=N->right_child=Node_list[used[0]++];} C->left_child=NULL; C->right_child=NULL; C->n=0; C->score=0; C->used=0; C->index=used[0]-1; } return find_val_in_bin_tree ( Node_list,C,index, bin_val, n+1, len, used); } }
void *vv_growk(void *x, int size, int k V_DEBUGPARAMS) { struct vec *v = VEC(x); if (!x) { v = vmalloc(sizeof *v + k * size); v->melt = k; v->nelt = k; v->size = size; v->csum = 0; return v+1; } assert(v->size == size); if (v->melt < (v->nelt += k)) { v->melt = 2 * (v->nelt); v = vrealloc(v, sizeof *v + v->melt * size); return v + 1; } return x; }
void *vv_growone(void *x, int size V_DEBUGPARAMS) { struct vec *v = VEC(x); if (!x) { v = vmalloc(sizeof *v + size); v->melt = 1; v->nelt = 1; v->size = size; v->csum = 0; return v+1; } assert(v->size == size); if (v->nelt++ == v->melt) { v->melt = 2 * v->melt + 1; v = vrealloc(v, sizeof *v + v->melt * size); return v + 1; } return x; }
void *vv_atleast(void *x, int size, int m V_DEBUGPARAMS) { struct vec *v = VEC(x); if (!x) { v = vmalloc(sizeof *v + m * size); v->melt = m; v->nelt = 0; v->size = size; v->csum = 0; return v+1; } assert(v->size == size); if (v->melt < m) { v->melt = v->melt + m; v = vrealloc(v, sizeof *v + v->melt * size); return v + 1; } return x; }
/** * Calculates the feature values for all sequences in a file. * * The File has to have fasta format. * \param seq_file_name The name of the file (in fasta format). * \param max_dist The maximal distance to be considered. * \param k_tup Size of the k_tup. * \param alphabet_size The size of the alphabet. * * \return The feature values for every sequence in a Cluster_info object. */ Cluster_info * feature_extract(char *seq_file_name, int max_dist, int k_tup, int *char2value, int alphabet_size, int * elem_2_compare, int *num_seq_p, int num_features) { char line[500]; FILE *tree_f = fopen(seq_file_name,"r"); // fgets(line, 500, tree_f); int num_seq = -1; int size = 1000; int matrix_size = 1000; const int STEP = 1000; int seq_pos = -1; char *seq = (char*)vcalloc(size, sizeof(char)); Cluster_info *matrix =(Cluster_info*) vcalloc(matrix_size, sizeof(Cluster_info)); char *c_p; int max_coding = pow(alphabet_size,k_tup); while (fgets(line, 500, tree_f) != NULL) { if (line[0] == '>') { if (num_seq >= 0) { seq[++seq_pos] = '\0'; if (num_seq > matrix_size -2) { matrix_size += STEP; matrix = (Cluster_info*)vrealloc(matrix, matrix_size * sizeof(Cluster_info)); } int *recoded_seq = recode_sequence(seq, seq_pos, char2value, alphabet_size, k_tup); matrix[num_seq].seq_number = num_seq; matrix[num_seq].elem_2_compare = elem_2_compare; matrix[num_seq].features=get_features(recoded_seq, seq_pos- k_tup +1, k_tup, max_coding, max_dist, num_features); vfree(recoded_seq); seq_pos = -1; } ++num_seq; } else { if (size - seq_pos < 500) { size += STEP; seq = (char*)vrealloc(seq, size*sizeof(char)); } c_p = &line[0]; while ((*c_p != '\n') && (*c_p != '\0')) { seq[++seq_pos] = toupper(*(c_p)); ++c_p; } } } fclose(tree_f); seq[++seq_pos] = '\0'; int *recoded_seq = recode_sequence(seq, seq_pos, char2value, alphabet_size, k_tup); matrix[num_seq].seq_number = num_seq; matrix[num_seq].elem_2_compare = elem_2_compare; matrix[num_seq].features=get_features(recoded_seq, seq_pos- k_tup +1, k_tup, max_coding, max_dist, num_features); *num_seq_p = ++num_seq; vfree(seq); vfree(recoded_seq); return matrix; }
void iterate(Fastal_param *param, void *method_arguments_p, char *aln_file_name, char *out_file_name_end, int iteration_number) { // calculate alignment length //count gap int it_coutner_2 = 0; const int LINE_LENGTH = 200; char line[LINE_LENGTH]; char *seq1 = (char*)vcalloc(1,sizeof(char)); char *seq2 = (char*)vcalloc(1,sizeof(char)); Fastal_profile **profiles =(Fastal_profile**) vcalloc(3,sizeof(Fastal_profile*)); initiate_profiles(profiles, param); Fastal_profile *gap_prf = profiles[0]; Fastal_profile *no_gap_prf = profiles[1]; int alphabet_size = param->alphabet_size; int *gap_list_1 = (int*)vcalloc(1, sizeof(int)); int *gap_list_1_length = (int*)vcalloc(1, sizeof(int)); *gap_list_1_length = 1; int num_gaps_1 = 0; int *gap_list_2 = (int*)vcalloc(1, sizeof(int)); int *gap_list_2_length = (int*)vcalloc(1, sizeof(int)); *gap_list_2_length = 1; int num_gaps_2 = 0; int alignment_length = 1; //from here repeat! int it_counter = 0; char *out_file_name = aln_file_name; int *gap_profile = (int*)vcalloc(alignment_length, sizeof(int)); // while (it_counter < alignment_length) // { FILE *alignment_file = fopen(aln_file_name,"r"); if (alignment_file == NULL) { printf("Could not open alignment file %s\n", aln_file_name); exit(1); } alignment_length = 0; int tmp_len = -1; fgets(line, LINE_LENGTH , alignment_file); while(fgets(line, LINE_LENGTH , alignment_file)!=NULL) { tmp_len = -1; if (line[0] == '>') { break; } while ((line[++tmp_len] != '\n') && (line[tmp_len] != '\0')); alignment_length += tmp_len; } // printf("ALN_LENGTH %i\n", alignment_length); seq1 =(char*)vrealloc(seq1, (1+alignment_length)*sizeof(char)); gap_profile = (int*)vrealloc(gap_profile, alignment_length * sizeof(int)); int i; for (i = 0; i < alignment_length; ++i) { gap_profile[i] = 0; } int number_of_sequences = 0; int pos = -1; fseek (alignment_file , 0 , SEEK_SET); while(fgets(line, LINE_LENGTH , alignment_file)!=NULL) { if (line[0] == '>') { ++number_of_sequences; pos = -1; } else { i = -1; while ((line[++i] != '\n') && (line[i] != '\0')) { ++pos; if (line[i] == '-') { ++gap_profile[pos]; } } } } double max_entrop = 0; int column_index = 0; double entrop = 0; double last = 0; double p; // for (i = it_counter; i<=it_counter; ++i) // { // p = gap_profile[i]/(double)number_of_sequences; // if (!p) // { // entrop = 0; // } // else // { // entrop = (-1)*(p*log(p) + (1-p)*log(1-p) ) ; // } // if (entrop > max_entrop) // { // column_index = i; // max_entrop = entrop; // } // last = entrop; // } // ++it_counter; // if (max_entrop < 0.6) // { // printf("CONTINUE %f\n",entrop); // continue; // } // column_index = 18;//it_counter-1; // if (column_index == 19) column_index = 58; out_file_name = vtmpnam(NULL); char *edit_file_name = "EDIT";//vtmpnam(NULL); FILE *edit_file = fopen(edit_file_name,"w"); char *profile_file_name = vtmpnam(NULL); FILE *profile_file = fopen(profile_file_name,"w"); char *split_file_name = "AHA";//vtmpnam(NULL); ++it_coutner_2; gap_prf = enlarge_prof(gap_prf, alignment_length, alphabet_size); no_gap_prf = enlarge_prof(no_gap_prf, alignment_length, alphabet_size ); no_gap_prf->number_of_sequences = 0; gap_prf->number_of_sequences = 0; split_set(alignment_file, gap_prf, no_gap_prf, seq1, column_index, param->char2pos, split_file_name); gap_prf -> length = alignment_length; no_gap_prf -> length = alignment_length; gap_list_1 = del_gap_from_profile(gap_prf, alphabet_size, gap_list_1, gap_list_1_length, &num_gaps_1 ); gap_list_2 = del_gap_from_profile(no_gap_prf, alphabet_size, gap_list_2, gap_list_2_length, &num_gaps_2 ); fclose(alignment_file); profiles[0] = gap_prf; profiles[1] = no_gap_prf; alignment_length = gotoh_dyn(profiles, param, method_arguments_p, 0, edit_file, profile_file, 0); seq1 =(char*)vrealloc(seq1, (1+alignment_length)*sizeof(char)); seq2 =(char*)vrealloc(seq2, (1+alignment_length)*sizeof(char)); fclose(edit_file); edit_file = fopen(edit_file_name,"r"); edit2seq_pattern(edit_file, seq1, seq2); fclose(edit_file); fclose(profile_file); write_iterated_aln(aln_file_name, out_file_name, split_file_name, seq1, gap_list_1, num_gaps_1, seq2, gap_list_2, num_gaps_2); aln_file_name = out_file_name; // if (it_coutner_2 == 2) // break; // } char command[1000]; sprintf(command, "mv %s %s",out_file_name, out_file_name_end); system(command); vfree(seq1); vfree(seq2); vfree(gap_list_1); vfree(gap_list_2); if (!strcmp(param->method, "fast")) { free_sparse((Sparse_dynamic_param*)method_arguments_p); } else if (!strcmp(param->method, "nw")) { free_nw((Nw_param*)method_arguments_p, alphabet_size); } else if (!strcmp(param->method, "gotoh")) { free_gotoh((Gotoh_param*)method_arguments_p, alphabet_size); } }
Segment* extend_diagonals(Diagonal *diagonals, int *num_diagonal, int l1, int l2) { // sort diagonal by diagonal number int i; // printf("INPUT_PRE\n"); // for (i = 0; i < num_diagonals; ++i) // { // printf("%i %i %i\n",diagonals[i].x, diagonals[i].y, diagonals[i].length); // } int num_diagonals = *num_diagonal; qsort (diagonals, num_diagonals, sizeof(Diagonal), diagonal_compare); // find nearest diagonal and expand // make shure that overlapping segments on the same diagonal are merged int diff; // printf("INPUT\n"); for (i = 0; i < num_diagonals; ++i) { printf("%i %i %i\n",diagonals[i].x, diagonals[i].y, diagonals[i].length); } for (i = 0; i < num_diagonals; ++i) { diagonals[i].end_exp = 0; diagonals[i].front_exp = 0; } int first = 0; int next = 1; while (next < num_diagonals) { if (!((diagonals[next].y >= diagonals[first].y) && diagonals[next].x <= diagonals[first].x)) { printf("%i %i %i %i %i %i\n",diagonals[first].x, diagonals[first].y, diagonals[next].x, diagonals[next].y, diagonals[first].y - diagonals[first].x, diagonals[next].y - diagonals[next].x); diff = diagonals[next].y - (diagonals[first].y + diagonals[first].length); if (diff > 0) { if ((diagonals[first].y - diagonals[first].x) != ((diagonals[next].y - diagonals[next].x))) { diagonals[first].end_exp = max(diagonals[first].end_exp, diff); diagonals[next].front_exp = max(diagonals[next].front_exp, diff); // if (diagonals[next].x - diagonals[next].front_exp < 0) while (diagonals[++first].x == -1); } else { printf("ICH TUWAS\n"); diagonals[first].length = diagonals[next].y + diagonals[next].length - diagonals[first].y; diagonals[first].end_exp = diagonals[next].end_exp; diagonals[next].x = -1; } } diff = diagonals[first].x - (diagonals[next].x + diagonals[next].length); if (diff > 0) { // diff = diagonals[next].x + diagonals[next].length - diagonals[first].x; diagonals[first].front_exp = max(diagonals[first].front_exp, diff); diagonals[next].end_exp = max(diagonals[next].end_exp, diff); // ++num_segments; // if (diagonals[first].x - diagonals[first].front_exp < 0) while (diagonals[++first].x == -1); } } else ++ first; ++next; } int num_segments =0; Segment *seg =(Segment*) vcalloc(num_diagonals, sizeof(Segment)); int pos = 0; // int diag_num1, diag_num2; int *tmp1; Diagonal *tmp2; for (i = 0; i < num_diagonals; ++i) { if (diagonals[i].x != -1) { ++num_segments; tmp2 = &diagonals[i]; seg[pos].segments =(int*) vcalloc(6, sizeof(int)); seg[pos].current_pos = seg[pos].segments; tmp1 = seg[pos].segments; tmp1[0] = tmp2->x - tmp2->front_exp; tmp1[1] = tmp2->y - tmp2->front_exp; tmp1[2] = tmp2->front_exp + tmp2->length + tmp2->end_exp; tmp1[5] = 1; tmp1[4] = l2; tmp1[3] = tmp1[0] + (l2 - tmp1[1]); ++pos; } } for ( i = 0; i < num_segments; ++i ) { printf("%i %i %i || %i %i %i\n", seg[i].current_pos[0], seg[i].current_pos[1], seg[i].current_pos[2], seg[i].current_pos[3], seg[i].current_pos[4], seg[i].current_pos[5]); } // exit(1); vrealloc(seg,num_segments*sizeof(Segment)); *num_diagonal = num_segments; // vfree(diagonals); return seg; }
HaschT* hasch_sequence ( char *seq1, int ktup) { char c; int key, offset=0, ls; HaschT *H; Hasch_entry *e; H=hcreate ( strlen (seq1), declare_ktup_hasch_data, free_ktup_hasch_data); ls=strlen (seq1); while (ls>=(ktup)) { c=seq1[ktup];seq1[ktup]='\0'; key=string2key (seq1, NULL); e=hsearch (H,key,FIND, declare_ktup_hasch_data, free_ktup_hasch_data); if (e==NULL) { e=hsearch (H,key,ADD,declare_ktup_hasch_data,free_ktup_hasch_data); (e->data)->list[++(e->data)->list[1]+1]=offset; } else { if ((e->data)->list[0]==((e->data)->list[1]+2)){(e->data)->list[0]+=10;(e->data)->list=(int*)vrealloc ((e->data)->list,(e->data)->list[0]*sizeof (int));} (e->data)->list[++(e->data)->list[1]+1]=offset; } seq1[ktup]=c;seq1++;ls--; offset++; } return H; }